Changeset ac5816d


Ignore:
Timestamp:
Dec 27, 2020, 5:13:31 PM (4 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:
1e6f632f, b19fdb9
Parents:
c20533ea
Message:

Some clean-up and format changes to make concurrency files consistent

Location:
libcfa/src/concurrency
Files:
3 edited

Legend:

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

    rc20533ea rac5816d  
    55#include <stdlib.hfa>
    66
    7 ///////////////////////////////////////////////////////////////////
    8 //// info_thread
    9 ///////////////////////////////////////////////////////////////////
    10 
     7//-----------------------------------------------------------------------------
     8// info_thread
    119forall(dtype L | is_blocking_lock(L)) {
    12         void ?{}( info_thread(L) & this, $thread * t ) {
    13                 ((Seqable &) this){};
    14                 this.t = t;
    15                 this.lock = 0p;
    16         }
    17 
    18         void ?{}( info_thread(L) & this, $thread * t, uintptr_t info ) {
     10        struct info_thread {
     11                // used to put info_thread on a dl queue (aka sequence)
     12                inline Seqable;
     13
     14                // waiting thread
     15                struct $thread * t;
     16
     17                // shadow field
     18                uintptr_t info;
     19
     20                // lock that is passed to wait() (if one is passed)
     21                L * lock;
     22
     23                // true when signalled and false when timeout wakes thread
     24                bool signalled;
     25        };
     26
     27        void ?{}( info_thread(L) & this, $thread * t, uintptr_t info, L * l ) {
    1928                ((Seqable &) this){};
    2029                this.t = t;
    2130                this.info = info;
    22                 this.lock = 0p;
    23         }
    24 
    25         void ^?{}( info_thread(L) & this ){ }
     31                this.lock = l;
     32        }
     33
     34        void ^?{}( info_thread(L) & this ) {}
    2635
    2736        info_thread(L) *& Back( info_thread(L) * this ) {
     
    3443}
    3544
    36 ///////////////////////////////////////////////////////////////////
    37 //// Blocking Locks
    38 ///////////////////////////////////////////////////////////////////
    39 
     45//-----------------------------------------------------------------------------
     46// Blocking Locks
    4047void ?{}( blocking_lock & this, bool multi_acquisition, bool strict_owner ) {
    4148        this.lock{};
     
    4956
    5057void ^?{}( blocking_lock & this ) {}
    51 void ?{}( single_acquisition_lock & this ) {((blocking_lock &)this){ false, false };}
     58void  ?{}( single_acquisition_lock & this ) {((blocking_lock &)this){ false, false };}
    5259void ^?{}( single_acquisition_lock & this ) {}
    53 void ?{}( owner_lock & this ) {((blocking_lock &)this){ true, true };}
     60void  ?{}( owner_lock & this ) {((blocking_lock &)this){ true, true };}
    5461void ^?{}( owner_lock & this ) {}
    55 void ?{}( multiple_acquisition_lock & this ) {((blocking_lock &)this){ true, false };}
     62void  ?{}( multiple_acquisition_lock & this ) {((blocking_lock &)this){ true, false };}
    5663void ^?{}( multiple_acquisition_lock & this ) {}
    5764
    5865void lock( blocking_lock & this ) with( this ) {
    5966        lock( lock __cfaabi_dbg_ctx2 );
    60         if ( owner == active_thread() && !multi_acquisition) { // single acquisition lock is held by current thread
    61                 abort("A single acquisition lock holder attempted to reacquire the lock resulting in a deadlock.");
    62         } else if ( owner != 0p && owner != active_thread() ) { // lock is held by some other thread
    63                 addTail( blocked_threads, *active_thread() );
     67        $thread * thrd = active_thread();
     68
     69        // single acquisition lock is held by current thread
     70        /* paranoid */ verifyf( owner != thrd || multi_acquisition, "Single acquisition lock holder (%p) attempted to reacquire the lock %p resulting in a deadlock.", owner, &this );
     71
     72        // lock is held by some other thread
     73        if ( owner != 0p && owner != thrd ) {
     74                addTail( blocked_threads, *thrd );
    6475                wait_count++;
    6576                unlock( lock );
    6677                park( );
    67         } else if ( owner == active_thread() && multi_acquisition ) { // multi acquisition lock is held by current thread
     78        }
     79        // multi acquisition lock is held by current thread
     80        else if ( owner == thrd && multi_acquisition ) {
    6881                recursion_count++;
    6982                unlock( lock );
    70         } else { // lock isn't held
    71                 owner = active_thread();
     83        }
     84        // lock isn't held
     85        else {
     86                owner = thrd;
    7287                recursion_count = 1;
    7388                unlock( lock );
     
    7893        bool ret = false;
    7994        lock( lock __cfaabi_dbg_ctx2 );
    80         if ( owner == 0p ) { // lock isn't held
     95
     96        // lock isn't held
     97        if ( owner == 0p ) {
    8198                owner = active_thread();
    8299                recursion_count = 1;
    83100                ret = true;
    84         } else if ( owner == active_thread() && multi_acquisition ) { // multi acquisition lock is held by current thread
     101        }
     102        // multi acquisition lock is held by current thread
     103        else if ( owner == active_thread() && multi_acquisition ) {
    85104                recursion_count++;
    86105                ret = true;
    87106        }
     107
    88108        unlock( lock );
    89109        return ret;
    90 }
    91 
    92 void unlock_error_check( blocking_lock & this ) with( this ) {
    93         if ( owner == 0p ){ // lock isn't held
    94                 abort( "There was an attempt to release a lock that isn't held" );
    95         } else if ( strict_owner && owner != active_thread() ) {
    96                 abort( "A thread other than the owner attempted to release an owner lock" );
    97         }
    98110}
    99111
     
    108120void unlock( blocking_lock & this ) with( this ) {
    109121        lock( lock __cfaabi_dbg_ctx2 );
    110         unlock_error_check( this );
     122        /* paranoid */ verifyf( owner != 0p, "Attempt to release lock %p that isn't held", &this );
     123        /* paranoid */ verifyf( owner == active_thread() || !strict_owner, "Thread %p other than the owner %p attempted to release owner lock %p", owner, active_thread(), &this );
     124
     125        // if recursion count is zero release lock and set new owner if one is waiting
    111126        recursion_count--;
    112         if ( recursion_count == 0 ) { // if recursion count is zero release lock and set new owner if one is waiting
     127        if ( recursion_count == 0 ) {
    113128                pop_and_set_new_owner( this );
    114129        }
     
    129144
    130145void on_notify( blocking_lock & this, $thread * t ) with( this ) {
    131     lock( lock __cfaabi_dbg_ctx2 );
    132         if ( owner != 0p ) { // lock held
     146        lock( lock __cfaabi_dbg_ctx2 );
     147        // lock held
     148        if ( owner != 0p ) {
    133149                addTail( blocked_threads, *t );
    134150                wait_count++;
    135151                unlock( lock );
    136         } else {        // lock not held
     152        }
     153        // lock not held
     154        else {
    137155                owner = t;
    138156                recursion_count = 1;
     
    143161
    144162void on_wait( blocking_lock & this ) with( this ) {
    145     lock( lock __cfaabi_dbg_ctx2 );
    146         unlock_error_check( this );
     163        lock( lock __cfaabi_dbg_ctx2 );
     164        /* paranoid */ verifyf( owner != 0p, "Attempt to release lock %p that isn't held", &this );
     165        /* paranoid */ verifyf( owner == active_thread() || !strict_owner, "Thread %p other than the owner %p attempted to release owner lock %p", owner, active_thread(), &this );
     166
    147167        pop_and_set_new_owner( this );
    148168        unlock( lock );
    149169}
    150170
    151 ///////////////////////////////////////////////////////////////////
    152 //// Overloaded routines for traits
    153 ///////////////////////////////////////////////////////////////////
    154 
     171//-----------------------------------------------------------------------------
     172// Overloaded routines for traits
    155173// These routines are temporary until an inheritance bug is fixed
    156 
    157 void lock( single_acquisition_lock & this ){ lock( (blocking_lock &)this ); }
    158 void unlock( single_acquisition_lock & this ){ unlock( (blocking_lock &)this ); }
    159 void on_notify( single_acquisition_lock & this, struct $thread * t ){ on_notify( (blocking_lock &)this, t ); }
    160 void on_wait( single_acquisition_lock & this ){ on_wait( (blocking_lock &)this ); }
    161 void set_recursion_count( single_acquisition_lock & this, size_t recursion ){ set_recursion_count( (blocking_lock &)this, recursion ); }
    162 size_t get_recursion_count( single_acquisition_lock & this ){ return get_recursion_count( (blocking_lock &)this ); }
    163 
    164 void lock( owner_lock & this ){ lock( (blocking_lock &)this ); }
    165 void unlock( owner_lock & this ){ unlock( (blocking_lock &)this ); }
    166 void on_notify( owner_lock & this, struct $thread * t ){ on_notify( (blocking_lock &)this, t ); }
    167 void on_wait( owner_lock & this ){ on_wait( (blocking_lock &)this ); }
    168 void set_recursion_count( owner_lock & this, size_t recursion ){ set_recursion_count( (blocking_lock &)this, recursion ); }
    169 size_t get_recursion_count( owner_lock & this ){ return get_recursion_count( (blocking_lock &)this ); }
    170 
    171 void lock( multiple_acquisition_lock & this ){ lock( (blocking_lock &)this ); }
    172 void unlock( multiple_acquisition_lock & this ){ unlock( (blocking_lock &)this ); }
    173 void on_notify( multiple_acquisition_lock & this, struct $thread * t ){ on_notify( (blocking_lock &)this, t ); }
    174 void on_wait( multiple_acquisition_lock & this ){ on_wait( (blocking_lock &)this ); }
    175 void set_recursion_count( multiple_acquisition_lock & this, size_t recursion ){ set_recursion_count( (blocking_lock &)this, recursion ); }
     174void   lock      ( single_acquisition_lock & this ) { lock   ( (blocking_lock &)this ); }
     175void   unlock    ( single_acquisition_lock & this ) { unlock ( (blocking_lock &)this ); }
     176void   on_wait   ( single_acquisition_lock & this ) { on_wait( (blocking_lock &)this ); }
     177void   on_notify ( single_acquisition_lock & this, struct $thread * t ) { on_notify( (blocking_lock &)this, t ); }
     178void   set_recursion_count( single_acquisition_lock & this, size_t recursion ) { set_recursion_count( (blocking_lock &)this, recursion ); }
     179size_t get_recursion_count( single_acquisition_lock & this ) { return get_recursion_count( (blocking_lock &)this ); }
     180
     181void   lock     ( owner_lock & this ) { lock   ( (blocking_lock &)this ); }
     182void   unlock   ( owner_lock & this ) { unlock ( (blocking_lock &)this ); }
     183void   on_wait  ( owner_lock & this ) { on_wait( (blocking_lock &)this ); }
     184void   on_notify( owner_lock & this, struct $thread * t ) { on_notify( (blocking_lock &)this, t ); }
     185void   set_recursion_count( owner_lock & this, size_t recursion ) { set_recursion_count( (blocking_lock &)this, recursion ); }
     186size_t get_recursion_count( owner_lock & this ) { return get_recursion_count( (blocking_lock &)this ); }
     187
     188void   lock     ( multiple_acquisition_lock & this ) { lock   ( (blocking_lock &)this ); }
     189void   unlock   ( multiple_acquisition_lock & this ) { unlock ( (blocking_lock &)this ); }
     190void   on_wait  ( multiple_acquisition_lock & this ) { on_wait( (blocking_lock &)this ); }
     191void   on_notify( multiple_acquisition_lock & this, struct $thread * t ){ on_notify( (blocking_lock &)this, t ); }
     192void   set_recursion_count( multiple_acquisition_lock & this, size_t recursion ){ set_recursion_count( (blocking_lock &)this, recursion ); }
    176193size_t get_recursion_count( multiple_acquisition_lock & this ){ return get_recursion_count( (blocking_lock &)this ); }
    177194
    178 
     195//-----------------------------------------------------------------------------
     196// alarm node wrapper
    179197forall(dtype L | is_blocking_lock(L)) {
    180198        struct alarm_node_wrap {
     
    184202        };
    185203
    186         void ?{}( alarm_node_wrap(L) & this, Time alarm, Duration period, Alarm_Callback callback ) {
     204        void ?{}( alarm_node_wrap(L) & this, Time alarm, Duration period, Alarm_Callback callback, condition_variable(L) * c, info_thread(L) * i ) {
    187205                this.alarm_node{ callback, alarm, period };
     206                this.cond = c;
     207                this.i = i;
    188208        }
    189209
     
    191211
    192212        void timeout_handler ( alarm_node_wrap(L) & this ) with( this ) {
    193         // This condition_variable member is called from the kernel, and therefore, cannot block, but it can spin.
    194             lock( cond->lock __cfaabi_dbg_ctx2 );
    195 
    196             // this check is necessary to avoid a race condition since this timeout handler
    197             //  may still be called after a thread has been removed from the queue but
    198             //  before the alarm is unregistered
    199             if ( listed(i) ) {                                                  // is thread on queue
    200                 i->signalled = false;
    201                         remove( cond->blocked_threads, *i );    // remove this thread O(1)
     213                // This condition_variable member is called from the kernel, and therefore, cannot block, but it can spin.
     214                lock( cond->lock __cfaabi_dbg_ctx2 );
     215
     216                // this check is necessary to avoid a race condition since this timeout handler
     217                //      may still be called after a thread has been removed from the queue but
     218                //      before the alarm is unregistered
     219                if ( listed(i) ) {      // is thread on queue
     220                        i->signalled = false;
     221                        // remove this thread O(1)
     222                        remove( cond->blocked_threads, *i );
    202223                        cond->count--;
    203224                        if( i->lock ) {
    204                                 on_notify(*i->lock, i->t);                      // call lock's on_notify if a lock was passed
    205                 } else {
    206                         unpark( i->t );                                         // otherwise wake thread
    207                 }
    208             }
    209             unlock( cond->lock );
     225                                // call lock's on_notify if a lock was passed
     226                                on_notify(*i->lock, i->t);
     227                        } else {
     228                                // otherwise wake thread
     229                                unpark( i->t );
     230                        }
     231                }
     232                unlock( cond->lock );
    210233        }
    211234
    212235        // this casts the alarm node to our wrapped type since we used type erasure
    213236        void alarm_node_wrap_cast( alarm_node_t & a ) { timeout_handler( (alarm_node_wrap(L) &)a ); }
    214 
    215 }
    216 
    217 ///////////////////////////////////////////////////////////////////
    218 //// condition variable
    219 ///////////////////////////////////////////////////////////////////
    220 
     237}
     238
     239//-----------------------------------------------------------------------------
     240// condition variable
    221241forall(dtype L | is_blocking_lock(L)) {
    222242
     
    234254                        count--;
    235255                        if (popped.lock) {
    236                                 on_notify(*popped.lock, popped.t); // if lock passed call on_notify
     256                                // if lock passed call on_notify
     257                                on_notify(*popped.lock, popped.t);
    237258                        } else {
    238                                 unpark(popped.t); // otherwise wake thread
     259                                // otherwise wake thread
     260                                unpark(popped.t);
    239261                        }
    240262                }
     
    268290
    269291        size_t queue_and_get_recursion( condition_variable(L) & this, info_thread(L) * i ) with(this) {
    270                 addTail( blocked_threads, *i ); // add info_thread to waiting queue
     292                // add info_thread to waiting queue
     293                addTail( blocked_threads, *i );
    271294                count++;
    272295                size_t recursion_count = 0;
    273                 if (i->lock) { // if lock was passed get recursion count to reset to after waking thread
     296                if (i->lock) {
     297                        // if lock was passed get recursion count to reset to after waking thread
    274298                        recursion_count = get_recursion_count(*i->lock);
    275299                        on_wait( *i->lock );
     
    283307                size_t recursion_count = queue_and_get_recursion(this, &i);
    284308                unlock( lock );
    285                 park( ); // blocks here
    286                 if (i.lock) set_recursion_count(*i.lock, recursion_count); // resets recursion count here after waking
    287         }
     309
     310                // blocks here
     311                park( );
     312
     313                // resets recursion count here after waking
     314                if (i.lock) set_recursion_count(*i.lock, recursion_count);
     315        }
     316
     317        #define WAIT( u, l ) \
     318                info_thread( L ) i = { active_thread(), u, l }; \
     319                queue_info_thread( this, i );
    288320
    289321        // helper for wait()'s' with a timeout
     
    291323                lock( lock __cfaabi_dbg_ctx2 );
    292324                size_t recursion_count = queue_and_get_recursion(this, &info);
    293                 alarm_node_wrap(L) node_wrap = { t, 0`s, alarm_node_wrap_cast };
    294                 node_wrap.cond = &this;
    295                 node_wrap.i = &info;
     325                alarm_node_wrap(L) node_wrap = { t, 0`s, alarm_node_wrap_cast, &this, &info };
    296326                register_self( &node_wrap.alarm_node );
    297327                unlock( lock );
     328
     329                // blocks here
    298330                park();
    299                 unregister_self( &node_wrap.alarm_node ); // unregisters alarm so it doesn't go off if this happens first
    300                 if (info.lock) set_recursion_count(*info.lock, recursion_count); // resets recursion count here after waking
    301         }
    302 
    303         void wait( condition_variable(L) & this ) with(this) {
    304                 info_thread( L ) i = { active_thread() };
    305                 queue_info_thread( this, i );
    306         }
    307 
    308         void wait( condition_variable(L) & this, uintptr_t info ) with(this) {
    309                 info_thread( L ) i = { active_thread(), info };
    310                 queue_info_thread( this, i );
    311         }
    312        
    313         bool wait( condition_variable(L) & this, Duration duration ) with(this) {
    314                 info_thread( L ) i = { active_thread() };
    315                 queue_info_thread_timeout(this, i, __kernel_get_time() + duration );
     331
     332                // unregisters alarm so it doesn't go off if this happens first
     333                unregister_self( &node_wrap.alarm_node );
     334
     335                // resets recursion count here after waking
     336                if (info.lock) set_recursion_count(*info.lock, recursion_count);
     337        }
     338
     339        #define WAIT_TIME( u, l, t ) \
     340                info_thread( L ) i = { active_thread(), u, l }; \
     341                queue_info_thread_timeout(this, i, t ); \
    316342                return i.signalled;
    317         }
    318 
    319         bool wait( condition_variable(L) & this, uintptr_t info, Duration duration ) with(this) {
    320                 info_thread( L ) i = { active_thread(), info };
    321                 queue_info_thread_timeout(this, i, __kernel_get_time() + duration );
    322                 return i.signalled;
    323         }
    324 
    325         bool wait( condition_variable(L) & this, Time time ) with(this) {
    326                 info_thread( L ) i = { active_thread() };
    327                 queue_info_thread_timeout(this, i, time);
    328                 return i.signalled;
    329         }
    330 
    331         bool wait( condition_variable(L) & this, uintptr_t info, Time time ) with(this) {
    332                 info_thread( L ) i = { active_thread(), info };
    333                 queue_info_thread_timeout(this, i, time);
    334                 return i.signalled;
    335         }
    336 
    337         void wait( condition_variable(L) & this, L & l ) with(this) {
    338                 info_thread(L) i = { active_thread() };
    339                 i.lock = &l;
    340                 queue_info_thread( this, i );
    341         }
    342 
    343         void wait( condition_variable(L) & this, L & l, uintptr_t info ) with(this) {
    344                 info_thread(L) i = { active_thread(), info };
    345                 i.lock = &l;
    346                 queue_info_thread( this, i );
    347         }
    348        
    349         bool wait( condition_variable(L) & this, L & l, Duration duration ) with(this) {
    350                 info_thread(L) i = { active_thread() };
    351                 i.lock = &l;
    352                 queue_info_thread_timeout(this, i, __kernel_get_time() + duration );
    353                 return i.signalled;
    354         }
    355        
    356         bool wait( condition_variable(L) & this, L & l, uintptr_t info, Duration duration ) with(this) {
    357                 info_thread(L) i = { active_thread(), info };
    358                 i.lock = &l;
    359                 queue_info_thread_timeout(this, i, __kernel_get_time() + duration );
    360                 return i.signalled;
    361         }
    362        
    363         bool wait( condition_variable(L) & this, L & l, Time time ) with(this) {
    364                 info_thread(L) i = { active_thread() };
    365                 i.lock = &l;
    366                 queue_info_thread_timeout(this, i, time );
    367                 return i.signalled;
    368         }
    369        
    370         bool wait( condition_variable(L) & this, L & l, uintptr_t info, Time time ) with(this) {
    371                 info_thread(L) i = { active_thread(), info };
    372                 i.lock = &l;
    373                 queue_info_thread_timeout(this, i, time );
    374                 return i.signalled;
    375         }
    376 }
     343
     344        void wait( condition_variable(L) & this                        ) with(this) { WAIT( 0, 0p    ) }
     345        void wait( condition_variable(L) & this, uintptr_t info        ) with(this) { WAIT( info, 0p ) }
     346        void wait( condition_variable(L) & this, L & l                 ) with(this) { WAIT( 0, &l    ) }
     347        void wait( condition_variable(L) & this, L & l, uintptr_t info ) with(this) { WAIT( info, &l ) }
     348
     349        bool wait( condition_variable(L) & this, Duration duration                        ) with(this) { WAIT_TIME( 0   , 0p , __kernel_get_time() + duration ) }
     350        bool wait( condition_variable(L) & this, uintptr_t info, Duration duration        ) with(this) { WAIT_TIME( info, 0p , __kernel_get_time() + duration ) }
     351        bool wait( condition_variable(L) & this, Time time                                ) with(this) { WAIT_TIME( 0   , 0p , time ) }
     352        bool wait( condition_variable(L) & this, uintptr_t info, Time time                ) with(this) { WAIT_TIME( info, 0p , time ) }
     353        bool wait( condition_variable(L) & this, L & l, Duration duration                 ) with(this) { WAIT_TIME( 0   , &l , __kernel_get_time() + duration ) }
     354        bool wait( condition_variable(L) & this, L & l, uintptr_t info, Duration duration ) with(this) { WAIT_TIME( info, &l , __kernel_get_time() + duration ) }
     355        bool wait( condition_variable(L) & this, L & l, Time time                         ) with(this) { WAIT_TIME( 0   , &l , time ) }
     356        bool wait( condition_variable(L) & this, L & l, uintptr_t info, Time time         ) with(this) { WAIT_TIME( info, &l , time ) }
     357}
  • libcfa/src/concurrency/locks.hfa

    rc20533ea rac5816d  
    1010#include "time_t.hfa"
    1111#include "time.hfa"
    12 #include <sys/time.h>
    1312
    14 ///////////////////////////////////////////////////////////////////
    15 //// is_blocking_lock
    16 ///////////////////////////////////////////////////////////////////
     13//-----------------------------------------------------------------------------
     14// is_blocking_lock
     15trait is_blocking_lock(dtype L | sized(L)) {
     16        // For synchronization locks to use when acquiring
     17        void on_notify( L &, struct $thread * );
    1718
    18 trait is_blocking_lock(dtype L | sized(L)) {
    19         void on_notify( L &, struct $thread * );                        // For synchronization locks to use when acquiring
    20         void on_wait( L & );                                                            // For synchronization locks to use when releasing
    21         size_t get_recursion_count( L & );                                      // to get recursion count for cond lock to reset after waking
    22         void set_recursion_count( L &, size_t recursion );      // to set recursion count after getting signalled;
     19        // For synchronization locks to use when releasing
     20        void on_wait( L & );
     21
     22        // to get recursion count for cond lock to reset after waking
     23        size_t get_recursion_count( L & );
     24
     25        // to set recursion count after getting signalled;
     26        void set_recursion_count( L &, size_t recursion );
    2327};
    2428
    25 ///////////////////////////////////////////////////////////////////
    26 //// info_thread
    27 ///////////////////////////////////////////////////////////////////
    28 
     29//-----------------------------------------------------------------------------
     30// info_thread
    2931// the info thread is a wrapper around a thread used
    3032// to store extra data for use in the condition variable
    3133forall(dtype L | is_blocking_lock(L)) {
    32         struct info_thread {
    33                 inline Seqable;                                 // used to put info_thread on a dl queue (aka sequence)
    34                 struct $thread * t;                             // waiting thread
    35                 uintptr_t info;                                 // shadow field
    36                 L * lock;                                               // lock that is passed to wait() (if one is passed)
    37                 bool signalled;                                 // true when signalled and false when timeout wakes thread
    38         };
    39 
    40 
    41         void ?{}( info_thread(L) & this, $thread * t );
    42         void ?{}( info_thread(L) & this, $thread * t, uintptr_t info );
    43         void ^?{}( info_thread(L) & this );
     34        struct info_thread;
    4435
    4536        // for use by sequence
     
    4839}
    4940
    50 ///////////////////////////////////////////////////////////////////
    51 //// Blocking Locks
    52 ///////////////////////////////////////////////////////////////////
    53 
     41//-----------------------------------------------------------------------------
     42// Blocking Locks
    5443struct blocking_lock {
    5544        // Spin lock used for mutual exclusion
     
    8776};
    8877
    89 void ?{}( blocking_lock & this, bool multi_acquisition, bool strict_owner );
     78void  ?{}( blocking_lock & this, bool multi_acquisition, bool strict_owner );
    9079void ^?{}( blocking_lock & this );
    9180
    92 void ?{}( single_acquisition_lock & this );
     81void  ?{}( single_acquisition_lock & this );
    9382void ^?{}( single_acquisition_lock & this );
    9483
    95 void ?{}( owner_lock & this );
     84void  ?{}( owner_lock & this );
    9685void ^?{}( owner_lock & this );
    9786
    98 void ?{}( multiple_acquisition_lock & this );
     87void  ?{}( multiple_acquisition_lock & this );
    9988void ^?{}( multiple_acquisition_lock & this );
    10089
     
    129118size_t get_recursion_count( multiple_acquisition_lock & this );
    130119
    131 ///////////////////////////////////////////////////////////////////
    132 //// Synchronization Locks
    133 ///////////////////////////////////////////////////////////////////
     120//-----------------------------------------------------------------------------
     121// Synchronization Locks
    134122forall(dtype L | is_blocking_lock(L)) {
    135123        struct condition_variable {
     
    144132        };
    145133
    146         void ?{}( condition_variable(L) & this );
     134        void  ?{}( condition_variable(L) & this );
    147135        void ^?{}( condition_variable(L) & this );
    148136
     
    152140        uintptr_t front( condition_variable(L) & this );
    153141
    154         bool empty( condition_variable(L) & this );
    155         int counter( condition_variable(L) & this );
     142        bool empty  ( condition_variable(L) & this );
     143        int  counter( condition_variable(L) & this );
    156144
    157145        void wait( condition_variable(L) & this );
  • libcfa/src/concurrency/thread.cfa

    rc20533ea rac5816d  
    133133
    134134        this_thrd->context.[SP, FP] = this_thrd->self_cor.context.[SP, FP];
    135         verify( this_thrd->context.SP );
     135        /* paranoid */ verify( this_thrd->context.SP );
    136136
    137137        __schedule_thread( this_thrd );
Note: See TracChangeset for help on using the changeset viewer.