Ignore:
Timestamp:
Dec 21, 2020, 1:55:24 PM (3 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
3d19ae6, d411769c
Parents:
5d369c7 (diff), 276a94d7 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

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

    r5d369c7 r7b1f6d4  
    1717                this.t = t;
    1818                this.lock = 0p;
    19                 this.listed = false;
    2019        }
    2120
     
    2524                this.info = info;
    2625                this.lock = 0p;
    27                 this.listed = false;
    2826        }
    2927
     
    3634        info_thread(L) *& Next( info_thread(L) * this ) {
    3735                return (info_thread(L) *)Next( (Colable *)this );
    38         }
    39 
    40         bool listed( info_thread(L) * this ) {
    41                 return Next( (Colable *)this ) != 0p;
    4236        }
    4337}
     
    194188        // This condition_variable member is called from the kernel, and therefore, cannot block, but it can spin.
    195189            lock( cond->lock __cfaabi_dbg_ctx2 );
    196            
    197             if ( i->listed ) {                  // is thread on queue
     190            if ( listed(i) ) {                  // is thread on queue
     191                i->signalled = false;
    198192                cond->last_thread = i;          // REMOVE THIS AFTER DEBUG
    199193                        remove( cond->blocked_threads, *i );             //remove this thread O(1)
     
    227221        void process_popped( condition_variable(L) & this, info_thread(L) & popped ) with( this ) {
    228222                if(&popped != 0p) {
    229                         popped.listed = false;
     223                        popped.signalled = true;
    230224                        count--;
    231225                        if (popped.lock) {
     
    266260                addTail( blocked_threads, *i );
    267261                count++;
    268                 i->listed = true;
    269262                size_t recursion_count = 0;
    270263                if (i->lock) {
     
    308301        }
    309302       
    310         void wait( condition_variable(L) & this, Duration duration ) with(this) {
     303        bool wait( condition_variable(L) & this, Duration duration ) with(this) {
    311304                info_thread( L ) i = { active_thread() };
    312305                queue_info_thread_timeout(this, i, __kernel_get_time() + duration );
    313         }
    314 
    315         void wait( condition_variable(L) & this, uintptr_t info, Duration duration ) with(this) {
     306                return i.signalled;
     307        }
     308
     309        bool wait( condition_variable(L) & this, uintptr_t info, Duration duration ) with(this) {
    316310                info_thread( L ) i = { active_thread(), info };
    317311                queue_info_thread_timeout(this, i, __kernel_get_time() + duration );
    318         }
    319 
    320         void wait( condition_variable(L) & this, Time time ) with(this) {
     312                return i.signalled;
     313        }
     314
     315        bool wait( condition_variable(L) & this, Time time ) with(this) {
    321316                info_thread( L ) i = { active_thread() };
    322317                queue_info_thread_timeout(this, i, time);
    323         }
    324 
    325         void wait( condition_variable(L) & this, uintptr_t info, Time time ) with(this) {
     318                return i.signalled;
     319        }
     320
     321        bool wait( condition_variable(L) & this, uintptr_t info, Time time ) with(this) {
    326322                info_thread( L ) i = { active_thread(), info };
    327323                queue_info_thread_timeout(this, i, time);
     324                return i.signalled;
    328325        }
    329326
     
    340337        }
    341338       
    342         void wait( condition_variable(L) & this, L & l, Duration duration ) with(this) {
     339        bool wait( condition_variable(L) & this, L & l, Duration duration ) with(this) {
    343340                info_thread(L) i = { active_thread() };
    344341                i.lock = &l;
    345342                queue_info_thread_timeout(this, i, __kernel_get_time() + duration );
    346         }
    347        
    348         void wait( condition_variable(L) & this, L & l, uintptr_t info, Duration duration ) with(this) {
     343                return i.signalled;
     344        }
     345       
     346        bool wait( condition_variable(L) & this, L & l, uintptr_t info, Duration duration ) with(this) {
    349347                info_thread(L) i = { active_thread(), info };
    350348                i.lock = &l;
    351349                queue_info_thread_timeout(this, i, __kernel_get_time() + duration );
    352         }
    353        
    354         void wait( condition_variable(L) & this, L & l, Time time ) with(this) {
     350                return i.signalled;
     351        }
     352       
     353        bool wait( condition_variable(L) & this, L & l, Time time ) with(this) {
    355354                info_thread(L) i = { active_thread() };
    356355                i.lock = &l;
    357356                queue_info_thread_timeout(this, i, time );
    358         }
    359        
    360         void wait( condition_variable(L) & this, L & l, uintptr_t info, Time time ) with(this) {
     357                return i.signalled;
     358        }
     359       
     360        bool wait( condition_variable(L) & this, L & l, uintptr_t info, Time time ) with(this) {
    361361                info_thread(L) i = { active_thread(), info };
    362362                i.lock = &l;
    363363                queue_info_thread_timeout(this, i, time );
    364         }
    365 }
     364                return i.signalled;
     365        }
     366}
Note: See TracChangeset for help on using the changeset viewer.