Ignore:
Timestamp:
Dec 27, 2020, 5:13:31 PM (11 months ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
arm-eh, jacob/cs343-translation, master, new-ast-unique-expr
Children:
1e6f632, b19fdb9
Parents:
c20533ea
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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 );
Note: See TracChangeset for help on using the changeset viewer.