Skip to content

Commit 9851a90

Browse files
committed
initialize cur_thread, first task on thread 0
1 parent 8aee42a commit 9851a90

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/rt/rust_scheduler.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ rust_scheduler::rust_scheduler(rust_kernel *kernel,
1111
live_threads(num_threads),
1212
live_tasks(0),
1313
num_threads(num_threads),
14+
cur_thread(0),
1415
id(id)
1516
{
1617
create_task_threads();
@@ -87,9 +88,9 @@ rust_scheduler::create_task(rust_task *spawner, const char *name) {
8788
{
8889
scoped_lock with(lock);
8990
live_tasks++;
90-
if (++cur_thread >= num_threads)
91+
thread_no = cur_thread++;
92+
if (cur_thread >= num_threads)
9193
cur_thread = 0;
92-
thread_no = cur_thread;
9394
}
9495
rust_task_thread *thread = threads[thread_no];
9596
return thread->create_task(spawner, name);

0 commit comments

Comments
 (0)