- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/locks.cfa
rfece3d9 rbeeff61e 171 171 } 172 172 173 size_t on_wait( blocking_lock & this , __cfa_pre_park pp_fn, void * pp_datum) with( this ) {173 size_t on_wait( blocking_lock & this ) with( this ) { 174 174 lock( lock __cfaabi_dbg_ctx2 ); 175 175 /* paranoid */ verifyf( owner != 0p, "Attempt to release lock %p that isn't held", &this ); … … 184 184 unlock( lock ); 185 185 186 p re_park_then_park( pp_fn, pp_datum);186 park(); 187 187 188 188 return ret; … … 396 396 } 397 397 398 static size_t block_and_get_recursion( info_thread(L) & i , __cfa_pre_park pp_fn, void * pp_datum) {398 static size_t block_and_get_recursion( info_thread(L) & i ) { 399 399 size_t recursion_count = 0; 400 400 if ( i.lock ) { 401 401 // if lock was passed get recursion count to reset to after waking thread 402 recursion_count = on_wait( *i.lock , pp_fn, pp_datum); // this call blocks403 } else p re_park_then_park( pp_fn, pp_datum);402 recursion_count = on_wait( *i.lock ); // this call blocks 403 } else park( ); 404 404 return recursion_count; 405 405 } 406 static size_t block_and_get_recursion( info_thread(L) & i ) { return block_and_get_recursion( i, pre_park_noop, 0p ); }407 406 408 407 // helper for wait()'s' with no timeout … … 425 424 queue_info_thread( this, i ); 426 425 427 static void cond_alarm_register( void * node_ptr ) { register_self( (alarm_node_t *)node_ptr ); }428 429 426 // helper for wait()'s' with a timeout 430 427 static void queue_info_thread_timeout( condition_variable(L) & this, info_thread(L) & info, Duration t, Alarm_Callback callback ) with(this) { … … 436 433 437 434 // registers alarm outside cond lock to avoid deadlock 438 //register_self( &node_wrap.alarm_node );435 register_self( &node_wrap.alarm_node ); 439 436 440 437 // blocks here 441 size_t recursion_count = block_and_get_recursion( info , cond_alarm_register, (void *)(&node_wrap.alarm_node));438 size_t recursion_count = block_and_get_recursion( info ); 442 439 // park(); 443 440 … … 506 503 info_thread( L ) i = { active_thread(), info, &l }; 507 504 insert_last( blocked_threads, i ); 508 size_t recursion_count = on_wait( *i.lock , pre_park_noop, 0p); // blocks here505 size_t recursion_count = on_wait( *i.lock ); // blocks here 509 506 // park( ); 510 507 on_wakeup(*i.lock, recursion_count); … … 555 552 // return recursion_count; 556 553 // } 554 557 555 558 556 static void queue_info_thread_timeout( pthread_cond_var(L) & this, info_thread(L) & info, Duration t, Alarm_Callback callback ) with(this) { … … 564 562 565 563 // registers alarm outside cond lock to avoid deadlock 566 // register_self( &node_wrap.alarm_node ); // C_TODO: fix race: registers itself and then alarm handler calls on_notify before block_and_get_recursion is run564 register_self( &node_wrap.alarm_node ); 567 565 568 566 // blocks here 569 size_t recursion_count = block_and_get_recursion( info , cond_alarm_register, (void *)(&node_wrap.alarm_node));567 size_t recursion_count = block_and_get_recursion( info ); 570 568 // park(); 571 569
Note:
See TracChangeset
for help on using the changeset viewer.