@@ -74,8 +74,6 @@ rust_task::rust_task(rust_task_thread *thread, rust_task_list *state,
74
74
cache(NULL ),
75
75
kernel(thread->kernel),
76
76
name(name),
77
- cond(NULL ),
78
- cond_name(" none" ),
79
77
list_index(-1 ),
80
78
next_port_id(0 ),
81
79
rendezvous_ptr(0 ),
@@ -87,6 +85,8 @@ rust_task::rust_task(rust_task_thread *thread, rust_task_list *state,
87
85
cc_counter(0 ),
88
86
total_stack_sz(0 ),
89
87
state(state),
88
+ cond(NULL ),
89
+ cond_name(" none" ),
90
90
killed(false ),
91
91
reentered_rust_stack(false ),
92
92
c_stack(NULL ),
@@ -242,7 +242,7 @@ rust_task::start(spawn_fn spawnee_fn,
242
242
243
243
void rust_task::start ()
244
244
{
245
- transition (&thread->newborn_tasks , &thread->running_tasks );
245
+ transition (&thread->newborn_tasks , &thread->running_tasks , NULL , " none " );
246
246
}
247
247
248
248
bool
@@ -369,7 +369,8 @@ rust_task::blocked()
369
369
bool
370
370
rust_task::blocked_on (rust_cond *on)
371
371
{
372
- return blocked () && cond == on;
372
+ scoped_lock with (state_lock);
373
+ return cond == on;
373
374
}
374
375
375
376
bool
@@ -398,7 +399,8 @@ rust_task::free(void *p)
398
399
}
399
400
400
401
void
401
- rust_task::transition (rust_task_list *src, rust_task_list *dst) {
402
+ rust_task::transition (rust_task_list *src, rust_task_list *dst,
403
+ rust_cond *cond, const char * cond_name) {
402
404
bool unlock = false ;
403
405
if (!thread->lock .lock_held_by_current_thread ()) {
404
406
unlock = true ;
@@ -413,6 +415,8 @@ rust_task::transition(rust_task_list *src, rust_task_list *dst) {
413
415
{
414
416
scoped_lock with (state_lock);
415
417
state = dst;
418
+ this ->cond = cond;
419
+ this ->cond_name = cond_name;
416
420
}
417
421
thread->lock .signal ();
418
422
if (unlock)
@@ -426,9 +430,7 @@ rust_task::block(rust_cond *on, const char* name) {
426
430
A (thread, cond == NULL , " Cannot block an already blocked task." );
427
431
A (thread, on != NULL , " Cannot block on a NULL object." );
428
432
429
- transition (&thread->running_tasks , &thread->blocked_tasks );
430
- cond = on;
431
- cond_name = name;
433
+ transition (&thread->running_tasks , &thread->blocked_tasks , on, name);
432
434
}
433
435
434
436
void
@@ -438,14 +440,12 @@ rust_task::wakeup(rust_cond *from) {
438
440
(uintptr_t ) cond, (uintptr_t ) from);
439
441
A (thread, cond == from, " Cannot wake up blocked task on wrong condition." );
440
442
441
- cond = NULL ;
442
- cond_name = " none" ;
443
- transition (&thread->blocked_tasks , &thread->running_tasks );
443
+ transition (&thread->blocked_tasks , &thread->running_tasks , NULL , " none" );
444
444
}
445
445
446
446
void
447
447
rust_task::die () {
448
- transition (&thread->running_tasks , &thread->dead_tasks );
448
+ transition (&thread->running_tasks , &thread->dead_tasks , NULL , " none " );
449
449
}
450
450
451
451
void
0 commit comments