Changeset 95a0824


Ignore:
Timestamp:
Oct 31, 2025, 11:44:20 AM (12 days ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
14a51d3
Parents:
b14d0d97
Message:

change counters from ssize_t to size_t

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/barrier.hfa

    rb14d0d97 r95a0824  
    1111// Created On       : Sun Nov 10 08:07:35 2024
    1212// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Thu Oct 30 21:20:18 2025
    14 // Update Count     : 67
     13// Last Modified On : Fri Oct 31 09:22:14 2025
     14// Update Count     : 69
    1515//
    1616
     
    2525
    2626monitor barrier {
    27         unsigned int group$, arrivals$;                                         // group size, arrival counter (backward)
     27        size_t group$, arrivals$;                                                       // group size, arrival counter (backward)
    2828        condition c$;                                                                           // wait for group to form
    2929        barrier_fptr_t callback$;                                                       // global callback
     
    3131};
    3232
    33 static inline void ?{}( barrier & b, unsigned int group, barrier_fptr_t callback, void * arg ) with ( b ) {
     33static inline void ?{}( barrier & b, ssize_t group, barrier_fptr_t callback, void * arg ) with ( b ) {
    3434        [group$, arrivals$] = group;
    3535        [callback$, arg$] = [callback, arg];
    3636}
    3737
    38 static inline void ?{}( barrier & b, unsigned int group ) { (b){ group, 0p, 0p }; }     // call base constructor
    39 static inline unsigned int waiters( barrier & b ) with( b ) { return group$ - arrivals$; }
    40 static inline unsigned int total( barrier & b ) with( b ) { return group$; }
     38static inline void ?{}( barrier & b, ssize_t group ) { (b){ group, 0p, 0p }; }  // call base constructor
     39static inline ssize_t waiters( barrier & b ) with( b ) { return group$ - arrivals$; }
     40static inline ssize_t total( barrier & b ) with( b ) { return group$; }
    4141
    4242// Returns a value indicating the reverse order the threads arrived, i.e., the Gth thread returns 0 (and does not
     
    4646
    4747// 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 ) {
     48static inline ssize_t block( barrier & mutex b, owner_lock & olock, barrier_fptr_t callback, void * arg ) with( b ) {
    4949        arrivals$ -= 1;                                                                         // prefix decrement so last is 0 not 1
    5050        typeof( arrivals$ ) arrived = arrivals$;                        // note arrival order
     
    6262}
    6363
    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 ); }
     64static inline ssize_t block( barrier & b ) { return block( b, *0p, 0p, 0p ); }
     65static inline ssize_t block( barrier & b, owner_lock & olock ) { return block( b, olock, 0p, 0p ); }
     66static inline ssize_t block( barrier & b, barrier_fptr_t callback ) { return block( b, *0p, callback, 0p ); }
     67static inline ssize_t block( barrier & b, barrier_fptr_t callback, void * arg ) { return block( b, *0p, callback, arg ); }
     68static 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.