File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -84,25 +84,27 @@ rust_kernel::fail() {
84
84
85
85
void
86
86
rust_kernel::register_task (rust_task *task) {
87
+ int new_live_tasks;
87
88
{
88
89
scoped_lock with (task_lock);
89
90
task->user .id = max_task_id++;
90
91
task_table.put (task->user .id , task);
92
+ new_live_tasks = ++live_tasks;
91
93
}
92
94
K (srv, task->user .id != INTPTR_MAX, " Hit the maximum task id" );
93
95
KLOG_ (" Registered task %" PRIdPTR, task->user .id );
94
- int new_live_tasks = sync::increment (live_tasks);
95
96
KLOG_ (" Total outstanding tasks: %d" , new_live_tasks);
96
97
}
97
98
98
99
void
99
100
rust_kernel::release_task_id (rust_task_id id) {
100
101
KLOG_ (" Releasing task %" PRIdPTR, id);
102
+ int new_live_tasks;
101
103
{
102
104
scoped_lock with (task_lock);
103
105
task_table.remove (id);
106
+ new_live_tasks = --live_tasks;
104
107
}
105
- int new_live_tasks = sync::decrement (live_tasks);
106
108
KLOG_ (" Total outstanding tasks: %d" , new_live_tasks);
107
109
if (new_live_tasks == 0 ) {
108
110
// There are no more tasks and there never will be.
Original file line number Diff line number Diff line change @@ -22,12 +22,13 @@ class rust_kernel {
22
22
private:
23
23
rust_scheduler *sched;
24
24
25
+ // Protects live_tasks, max_task_id and task_table
26
+ lock_and_signal task_lock;
25
27
// Tracks the number of tasks that are being managed by
26
28
// schedulers. When this hits 0 we will tell all schedulers
27
29
// to exit.
28
- volatile int live_tasks;
29
- // Protects max_task_id and task_table
30
- lock_and_signal task_lock;
30
+ int live_tasks;
31
+ // The next task id
31
32
rust_task_id max_task_id;
32
33
hash_map<rust_task_id, rust_task *> task_table;
33
34
You can’t perform that action at this time.
0 commit comments