Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/locks.cfa

    rfece3d9 rbeeff61e  
    171171}
    172172
    173 size_t on_wait( blocking_lock & this, __cfa_pre_park pp_fn, void * pp_datum ) with( this ) {
     173size_t on_wait( blocking_lock & this ) with( this ) {
    174174        lock( lock __cfaabi_dbg_ctx2 );
    175175        /* paranoid */ verifyf( owner != 0p, "Attempt to release lock %p that isn't held", &this );
     
    184184        unlock( lock );
    185185
    186     pre_park_then_park( pp_fn, pp_datum );
     186    park();
    187187
    188188        return ret;
     
    396396        }
    397397
    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 ) {
    399399        size_t recursion_count = 0;
    400400                if ( i.lock ) {
    401401                        // 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 blocks
    403                 } else pre_park_then_park( pp_fn, pp_datum );
     402                        recursion_count = on_wait( *i.lock ); // this call blocks
     403                } else park( );
    404404        return recursion_count;
    405405    }
    406     static size_t block_and_get_recursion( info_thread(L) & i ) { return block_and_get_recursion( i, pre_park_noop, 0p ); }
    407406
    408407        // helper for wait()'s' with no timeout
     
    425424                queue_info_thread( this, i );
    426425
    427     static void cond_alarm_register( void * node_ptr ) { register_self( (alarm_node_t *)node_ptr ); }
    428 
    429426        // helper for wait()'s' with a timeout
    430427        static void queue_info_thread_timeout( condition_variable(L) & this, info_thread(L) & info, Duration t, Alarm_Callback callback ) with(this) {
     
    436433
    437434                // registers alarm outside cond lock to avoid deadlock
    438                 // register_self( &node_wrap.alarm_node );
     435                register_self( &node_wrap.alarm_node );
    439436
    440437                // 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 );
    442439                // park();
    443440
     
    506503                info_thread( L ) i = { active_thread(), info, &l };
    507504                insert_last( blocked_threads, i );
    508                 size_t recursion_count = on_wait( *i.lock, pre_park_noop, 0p ); // blocks here
     505                size_t recursion_count = on_wait( *i.lock ); // blocks here
    509506                // park( );
    510507                on_wakeup(*i.lock, recursion_count);
     
    555552        //      return recursion_count;
    556553        // }
     554
    557555       
    558556        static void queue_info_thread_timeout( pthread_cond_var(L) & this, info_thread(L) & info, Duration t, Alarm_Callback callback ) with(this) {
     
    564562
    565563                // 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 run
     564                register_self( &node_wrap.alarm_node );
    567565
    568566                // 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 );
    570568                // park();
    571569
Note: See TracChangeset for help on using the changeset viewer.