Changeset 797a193 for libcfa/src/concurrency/locks.hfa
- Timestamp:
- Dec 22, 2020, 12:50:46 PM (2 years ago)
- Branches:
- arm-eh, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 26a249c, 302ef2a
- Parents:
- fe97de26
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/locks.hfa
rfe97de26 r797a193 6 6 #include "bits/locks.hfa" 7 7 #include "bits/sequence.hfa" 8 #include "bits/containers.hfa"9 8 10 9 #include "invoke.h" … … 20 19 21 20 trait is_blocking_lock(dtype L | sized(L)) { 22 void add_( L &, struct $thread * );// For synchronization locks to use when acquiring23 void remove_( L & );// For synchronization locks to use when releasing24 size_t get_recursion_count( L & ); // to get recursion count for cond lock to reset after waking25 void set_recursion_count( L &, size_t recursion ); 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; 26 25 }; 27 26 … … 30 29 /////////////////////////////////////////////////////////////////// 31 30 31 // the info thread is a wrapper around a thread used 32 // to store extra data for use in the condition variable 32 33 forall(dtype L | is_blocking_lock(L)) { 33 34 struct info_thread { 34 inline Seqable; 35 struct $thread * t; 36 uintptr_t info; 37 L * lock; 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) 38 39 bool signalled; // true when signalled and false when timeout wakes thread 39 40 }; … … 44 45 void ^?{}( info_thread(L) & this ); 45 46 47 // for use by sequence 46 48 info_thread(L) *& Back( info_thread(L) * this ); 47 49 info_thread(L) *& Next( info_thread(L) * this ); … … 102 104 bool try_lock( blocking_lock & this ); 103 105 void unlock( blocking_lock & this ); 104 void add_( blocking_lock & this, struct $thread * t );105 void remove_( blocking_lock & this );106 void on_notify( blocking_lock & this, struct $thread * t ); 107 void on_wait( blocking_lock & this ); 106 108 size_t wait_count( blocking_lock & this ); 107 109 void set_recursion_count( blocking_lock & this, size_t recursion ); … … 110 112 void lock( single_acquisition_lock & this ); 111 113 void unlock( single_acquisition_lock & this ); 112 void add_( single_acquisition_lock & this, struct $thread * t );113 void remove_( single_acquisition_lock & this );114 void on_notify( single_acquisition_lock & this, struct $thread * t ); 115 void on_wait( single_acquisition_lock & this ); 114 116 void set_recursion_count( single_acquisition_lock & this, size_t recursion ); 115 117 size_t get_recursion_count( single_acquisition_lock & this ); … … 117 119 void lock( owner_lock & this ); 118 120 void unlock( owner_lock & this ); 119 void add_( owner_lock & this, struct $thread * t );120 void remove_( owner_lock & this );121 void on_notify( owner_lock & this, struct $thread * t ); 122 void on_wait( owner_lock & this ); 121 123 void set_recursion_count( owner_lock & this, size_t recursion ); 122 124 size_t get_recursion_count( owner_lock & this ); … … 124 126 void lock( multiple_acquisition_lock & this ); 125 127 void unlock( multiple_acquisition_lock & this ); 126 void add_( multiple_acquisition_lock & this, struct $thread * t );127 void remove_( multiple_acquisition_lock & this );128 void on_notify( multiple_acquisition_lock & this, struct $thread * t ); 129 void on_wait( multiple_acquisition_lock & this ); 128 130 void set_recursion_count( multiple_acquisition_lock & this, size_t recursion ); 129 131 size_t get_recursion_count( multiple_acquisition_lock & this ); … … 136 138 // Spin lock used for mutual exclusion 137 139 __spinlock_t lock; 138 139 info_thread(L) * last_thread;140 140 141 141 // List of blocked threads
Note: See TracChangeset
for help on using the changeset viewer.