1
1
// Copyright 2022 TiKV Project Authors. Licensed under Apache-2.0.
2
2
3
3
//! A priority task queue. Tasks are scheduled based on its priority, tasks with small priority
4
- //! value will be scheduler earlier than bigger onces.. User should implement The [`TaskPriorityProvider`]
4
+ //! value will be scheduler earlier than bigger onces. User should implement The [`TaskPriorityProvider`]
5
5
//! to provide the priority value for each task. The priority value is fetched from the
6
6
//! [`TaskPriorityProvider`] at each time the task is scheduled.
7
7
//!
@@ -86,11 +86,11 @@ where
86
86
87
87
/// A trait used to generate priority value for each task.
88
88
pub trait TaskPriorityProvider : Send + Sync + ' static {
89
- /// Return a priority value of this task, all tasks in the priority queue is ordered by this value.
89
+ /// Return a priority value of this task, all tasks in the priority
90
+ /// queue is ordered by this value.
90
91
fn get_priority ( & self , extras : & Extras ) -> u64 ;
91
92
}
92
93
93
- ///
94
94
#[ derive( Clone ) ]
95
95
struct PriorityTaskManager {
96
96
level_manager : Arc < TaskLevelManager > ,
@@ -152,8 +152,8 @@ impl<T: TaskCell + Send + 'static> QueueCore<T> {
152
152
}
153
153
154
154
#[ inline]
155
- fn gen_key ( & self , weight : u64 ) -> MapKey {
156
- MapKey ( weight , self . sequence . fetch_add ( 1 , Ordering :: Relaxed ) )
155
+ fn gen_key ( & self , priority : u64 ) -> MapKey {
156
+ MapKey ( priority , self . sequence . fetch_add ( 1 , Ordering :: Relaxed ) )
157
157
}
158
158
}
159
159
@@ -265,8 +265,7 @@ pub struct Config {
265
265
}
266
266
267
267
impl Config {
268
- /// Sets the name of the multilevel task queue. Metrics of multilevel
269
- /// task queues are available if name is provided.
268
+ /// Sets the name of the priority task queue. Metrics are available if name is provided.
270
269
pub fn name ( mut self , name : Option < impl Into < String > > ) -> Self {
271
270
self . name = name. map ( Into :: into) ;
272
271
self
@@ -290,7 +289,7 @@ pub struct Builder {
290
289
}
291
290
292
291
impl Builder {
293
- /// Creates a multilevel task queue builder with specified config and [`TaskPriorityProvider`].
292
+ /// Creates a priority task queue builder with specified config and [`TaskPriorityProvider`].
294
293
pub fn new ( config : Config , priority_manager : Arc < dyn TaskPriorityProvider > ) -> Builder {
295
294
let Config {
296
295
name,
0 commit comments