Changeset 95a0824
- Timestamp:
- Oct 31, 2025, 11:44:20 AM (12 days ago)
- Branches:
- master
- Children:
- 14a51d3
- Parents:
- b14d0d97
- File:
-
- 1 edited
-
libcfa/src/concurrency/barrier.hfa (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/barrier.hfa
rb14d0d97 r95a0824 11 11 // Created On : Sun Nov 10 08:07:35 2024 12 12 // Last Modified By : Peter A. Buhr 13 // Last Modified On : Thu Oct 30 21:20:18202514 // Update Count : 6 713 // Last Modified On : Fri Oct 31 09:22:14 2025 14 // Update Count : 69 15 15 // 16 16 … … 25 25 26 26 monitor barrier { 27 unsigned int group$, arrivals$;// group size, arrival counter (backward)27 size_t group$, arrivals$; // group size, arrival counter (backward) 28 28 condition c$; // wait for group to form 29 29 barrier_fptr_t callback$; // global callback … … 31 31 }; 32 32 33 static inline void ?{}( barrier & b, unsigned int group, barrier_fptr_t callback, void * arg ) with ( b ) {33 static inline void ?{}( barrier & b, ssize_t group, barrier_fptr_t callback, void * arg ) with ( b ) { 34 34 [group$, arrivals$] = group; 35 35 [callback$, arg$] = [callback, arg]; 36 36 } 37 37 38 static inline void ?{}( barrier & b, unsigned int group ) { (b){ group, 0p, 0p }; } // call base constructor39 static inline unsigned int waiters( barrier & b ) with( b ) { return group$ - arrivals$; }40 static inline unsigned int total( barrier & b ) with( b ) { return group$; }38 static inline void ?{}( barrier & b, ssize_t group ) { (b){ group, 0p, 0p }; } // call base constructor 39 static inline ssize_t waiters( barrier & b ) with( b ) { return group$ - arrivals$; } 40 static inline ssize_t total( barrier & b ) with( b ) { return group$; } 41 41 42 42 // Returns a value indicating the reverse order the threads arrived, i.e., the Gth thread returns 0 (and does not … … 46 46 47 47 // Barrier is a monitor => implicit mutual exclusion. 48 static inline unsigned int block( barrier & mutex b, owner_lock & olock, barrier_fptr_t callback, void * arg ) with( b ) {48 static inline ssize_t block( barrier & mutex b, owner_lock & olock, barrier_fptr_t callback, void * arg ) with( b ) { 49 49 arrivals$ -= 1; // prefix decrement so last is 0 not 1 50 50 typeof( arrivals$ ) arrived = arrivals$; // note arrival order … … 62 62 } 63 63 64 static inline unsigned int block( barrier & b ) { return block( b, *0p, 0p, 0p ); }65 static inline unsigned int block( barrier & b, owner_lock & olock ) { return block( b, olock, 0p, 0p ); }66 static inline unsigned int block( barrier & b, barrier_fptr_t callback ) { return block( b, *0p, callback, 0p ); }67 static inline unsigned int block( barrier & b, barrier_fptr_t callback, void * arg ) { return block( b, *0p, callback, arg ); }68 static inline unsigned int block( barrier & b, owner_lock & olock, barrier_fptr_t callback ) { return block( b, olock, callback, 0p ); }64 static inline ssize_t block( barrier & b ) { return block( b, *0p, 0p, 0p ); } 65 static inline ssize_t block( barrier & b, owner_lock & olock ) { return block( b, olock, 0p, 0p ); } 66 static inline ssize_t block( barrier & b, barrier_fptr_t callback ) { return block( b, *0p, callback, 0p ); } 67 static inline ssize_t block( barrier & b, barrier_fptr_t callback, void * arg ) { return block( b, *0p, callback, arg ); } 68 static inline ssize_t block( barrier & b, owner_lock & olock, barrier_fptr_t callback ) { return block( b, olock, callback, 0p ); }
Note:
See TracChangeset
for help on using the changeset viewer.