Ignore:
Timestamp:
Dec 27, 2020, 5:59:35 PM (3 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
9536761, ee56a4f
Parents:
62a7cc0 (diff), ac5816d (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.hfa

    r62a7cc0 r1e6f632f  
    33#include <stdbool.h>
    44
    5 #include "bits/algorithm.hfa"
    65#include "bits/locks.hfa"
    76#include "bits/sequence.hfa"
     
    1110#include "time_t.hfa"
    1211#include "time.hfa"
    13 #include <sys/time.h>
    14 #include "alarm.hfa"
    1512
    16 ///////////////////////////////////////////////////////////////////
    17 //// is_blocking_lock
    18 ///////////////////////////////////////////////////////////////////
     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 * );
    1918
    20 trait is_blocking_lock(dtype L | sized(L)) {
    21         void on_notify( L &, struct $thread * );                        // For synchronization locks to use when acquiring
    22         void on_wait( L & );                                                            // For synchronization locks to use when releasing
    23         size_t get_recursion_count( L & );                                      // to get recursion count for cond lock to reset after waking
    24         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 );
    2527};
    2628
    27 ///////////////////////////////////////////////////////////////////
    28 //// info_thread
    29 ///////////////////////////////////////////////////////////////////
    30 
     29//-----------------------------------------------------------------------------
     30// info_thread
    3131// the info thread is a wrapper around a thread used
    3232// to store extra data for use in the condition variable
    3333forall(dtype L | is_blocking_lock(L)) {
    34         struct info_thread {
    35                 inline Seqable;                                 // used to put info_thread on a dl queue (aka sequence)
    36                 struct $thread * t;                             // waiting thread
    37                 uintptr_t info;                                 // shadow field
    38                 L * lock;                                               // lock that is passed to wait() (if one is passed)
    39                 bool signalled;                                 // true when signalled and false when timeout wakes thread
    40         };
    41 
    42 
    43         void ?{}( info_thread(L) & this, $thread * t );
    44         void ?{}( info_thread(L) & this, $thread * t, uintptr_t info );
    45         void ^?{}( info_thread(L) & this );
     34        struct info_thread;
    4635
    4736        // for use by sequence
     
    5039}
    5140
    52 ///////////////////////////////////////////////////////////////////
    53 //// Blocking Locks
    54 ///////////////////////////////////////////////////////////////////
    55 
     41//-----------------------------------------------------------------------------
     42// Blocking Locks
    5643struct blocking_lock {
    5744        // Spin lock used for mutual exclusion
     
    8976};
    9077
    91 void ?{}( blocking_lock & this, bool multi_acquisition, bool strict_owner );
     78void  ?{}( blocking_lock & this, bool multi_acquisition, bool strict_owner );
    9279void ^?{}( blocking_lock & this );
    9380
    94 void ?{}( single_acquisition_lock & this );
     81void  ?{}( single_acquisition_lock & this );
    9582void ^?{}( single_acquisition_lock & this );
    9683
    97 void ?{}( owner_lock & this );
     84void  ?{}( owner_lock & this );
    9885void ^?{}( owner_lock & this );
    9986
    100 void ?{}( multiple_acquisition_lock & this );
     87void  ?{}( multiple_acquisition_lock & this );
    10188void ^?{}( multiple_acquisition_lock & this );
    10289
     
    131118size_t get_recursion_count( multiple_acquisition_lock & this );
    132119
    133 ///////////////////////////////////////////////////////////////////
    134 //// Synchronization Locks
    135 ///////////////////////////////////////////////////////////////////
     120//-----------------------------------------------------------------------------
     121// Synchronization Locks
    136122forall(dtype L | is_blocking_lock(L)) {
    137123        struct condition_variable {
     
    146132        };
    147133
    148         void ?{}( condition_variable(L) & this );
     134        void  ?{}( condition_variable(L) & this );
    149135        void ^?{}( condition_variable(L) & this );
    150 
    151         struct alarm_node_wrap {
    152                 alarm_node_t alarm_node;
    153 
    154                 condition_variable(L) * cond;
    155 
    156                 info_thread(L) * i;
    157         };
    158 
    159         void ?{}( alarm_node_wrap(L) & this, Time alarm, Duration period, Alarm_Callback callback );
    160         void ^?{}( alarm_node_wrap(L) & this );
    161 
    162         void alarm_node_callback( alarm_node_wrap(L) & this );
    163 
    164         void alarm_node_wrap_cast( alarm_node_t & a );
    165136
    166137        bool notify_one( condition_variable(L) & this );
     
    169140        uintptr_t front( condition_variable(L) & this );
    170141
    171         bool empty( condition_variable(L) & this );
    172         int counter( condition_variable(L) & this );
     142        bool empty  ( condition_variable(L) & this );
     143        int  counter( condition_variable(L) & this );
    173144
    174145        void wait( condition_variable(L) & this );
Note: See TracChangeset for help on using the changeset viewer.