Skip to content

Commit 4a056c4

Browse files
committed
use group name in extras
Signed-off-by: glorv <glorvs@163.com>
1 parent dd767d2 commit 4a056c4

File tree

1 file changed

+12
-23
lines changed

1 file changed

+12
-23
lines changed

src/queue/extras.rs

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ pub struct Extras {
2828
pub(crate) fixed_level: Option<u8>,
2929
/// Number of execute times
3030
pub(crate) exec_times: u32,
31-
/// The task group id. Used in priority queue.
32-
pub(crate) group_id: u64,
31+
/// The task group name. Used in priority queue.
32+
pub(crate) group_name: String,
3333
}
3434

3535
impl Extras {
@@ -45,7 +45,7 @@ impl Extras {
4545
current_level: 0,
4646
fixed_level: None,
4747
exec_times: 0,
48-
group_id: 0,
48+
group_name: String::new(),
4949
}
5050
}
5151

@@ -68,23 +68,7 @@ impl Extras {
6868
current_level: fixed_level.unwrap_or(0),
6969
fixed_level,
7070
exec_times: 0,
71-
group_id: 0,
72-
}
73-
}
74-
75-
/// Creates an `Extra` for task cells pushed into a priority task queue
76-
/// with custom settings.
77-
pub fn new_priority(group_id: u64, task_id: u64, fixed_level: Option<u8>) -> Extras {
78-
Extras {
79-
start_time: Instant::now(),
80-
schedule_time: None,
81-
task_id,
82-
running_time: None,
83-
total_running_time: None,
84-
current_level: fixed_level.unwrap_or(0),
85-
fixed_level,
86-
exec_times: 0,
87-
group_id,
71+
group_name: String::new(),
8872
}
8973
}
9074

@@ -110,8 +94,13 @@ impl Extras {
11094
self.current_level
11195
}
11296

113-
/// Gets the group id of this task
114-
pub fn group_id(&self) -> u64 {
115-
self.group_id
97+
/// Gets the group name of this task.
98+
pub fn group_name(&self) -> &str {
99+
&self.group_name
100+
}
101+
102+
/// Set the group name of this task.
103+
pub fn set_group_name(&mut self, name: String) {
104+
self.group_name = name;
116105
}
117106
}

0 commit comments

Comments
 (0)