Ignore:
File:
1 edited

Legend:

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

    rbe73f30 r121be3e  
    3030        this.lock{};
    3131        this.blocked_threads{};
    32         this.is_locked = false;
    3332}
    3433
     
    4039        lock( lock __cfaabi_dbg_ctx2 );
    4140        if( is_locked ) {
    42                 append( blocked_threads, active_thread() );
    43                 unlock( lock );
    44                 park();
     41                append( blocked_threads, kernelTLS.this_thread );
     42                BlockInternal( &lock );
    4543        }
    4644        else {
     
    6462        lock( this.lock __cfaabi_dbg_ctx2 );
    6563        this.is_locked = (this.blocked_threads != 0);
    66         unpark(
     64        WakeThread(
    6765                pop_head( this.blocked_threads )
    6866        );
     
    8684        lock( lock __cfaabi_dbg_ctx2 );
    8785        if( owner == 0p ) {
    88                 owner = active_thread();
     86                owner = kernelTLS.this_thread;
    8987                recursion_count = 1;
    9088                unlock( lock );
    9189        }
    92         else if( owner == active_thread() ) {
     90        else if( owner == kernelTLS.this_thread ) {
    9391                recursion_count++;
    9492                unlock( lock );
    9593        }
    9694        else {
    97                 append( blocked_threads, active_thread() );
    98                 unlock( lock );
    99                 park();
     95                append( blocked_threads, kernelTLS.this_thread );
     96                BlockInternal( &lock );
    10097        }
    10198}
     
    105102        lock( lock __cfaabi_dbg_ctx2 );
    106103        if( owner == 0p ) {
    107                 owner = active_thread();
     104                owner = kernelTLS.this_thread;
    108105                recursion_count = 1;
    109106                ret = true;
    110107        }
    111         else if( owner == active_thread() ) {
     108        else if( owner == kernelTLS.this_thread ) {
    112109                recursion_count++;
    113110                ret = true;
     
    121118        recursion_count--;
    122119        if( recursion_count == 0 ) {
    123                 $thread * thrd = pop_head( blocked_threads );
     120                thread_desc * thrd = pop_head( blocked_threads );
    124121                owner = thrd;
    125122                recursion_count = (thrd ? 1 : 0);
    126                 unpark( thrd );
     123                WakeThread( thrd );
    127124        }
    128125        unlock( lock );
     
    141138void notify_one(condition_variable & this) with(this) {
    142139        lock( lock __cfaabi_dbg_ctx2 );
    143         unpark(
     140        WakeThread(
    144141                pop_head( this.blocked_threads )
    145142        );
     
    150147        lock( lock __cfaabi_dbg_ctx2 );
    151148        while(this.blocked_threads) {
    152                 unpark(
     149                WakeThread(
    153150                        pop_head( this.blocked_threads )
    154151                );
     
    159156void wait(condition_variable & this) {
    160157        lock( this.lock __cfaabi_dbg_ctx2 );
    161         append( this.blocked_threads, active_thread() );
    162         unlock( this.lock );
    163         park();
     158        append( this.blocked_threads, kernelTLS.this_thread );
     159        BlockInternal( &this.lock );
    164160}
    165161
     
    167163void wait(condition_variable & this, L & l) {
    168164        lock( this.lock __cfaabi_dbg_ctx2 );
    169         append( this.blocked_threads, active_thread() );
    170         unlock(l);
    171         unlock(this.lock);
    172         park();
     165        append( this.blocked_threads, kernelTLS.this_thread );
     166        void __unlock(void) {
     167                unlock(l);
     168                unlock(this.lock);
     169        }
     170        BlockInternal( __unlock );
    173171        lock(l);
    174172}
Note: See TracChangeset for help on using the changeset viewer.