Ignore:
Timestamp:
Aug 21, 2025, 11:14:05 PM (5 weeks ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
31be464
Parents:
1324fde
Message:

change type name condition_variable to cond_lock

Location:
libcfa/src/concurrency
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/clib/cfathread.cfa

    r1324fde r8dc8f68  
    450450        // Condition
    451451        struct cfathread_condition {
    452                 condition_variable(exp_backoff_then_block_lock) impl;
     452                cond_lock(exp_backoff_then_block_lock) impl;
    453453        };
    454454        int cfathread_cond_init(cfathread_cond_t *restrict cond, const cfathread_condattr_t *restrict) __attribute__((nonnull (1))) { *cond = new(); return 0; }
  • libcfa/src/concurrency/locks.cfa

    r1324fde r8dc8f68  
    246246        struct alarm_node_wrap {
    247247                alarm_node_t alarm_node;
    248                 condition_variable(L) * cond;
     248                cond_lock(L) * cond;
    249249                info_thread(L) * info_thd;
    250250        };
    251251
    252         void ?{}( alarm_node_wrap(L) & this, Duration alarm, Duration period, Alarm_Callback callback, condition_variable(L) * c, info_thread(L) * i ) {
     252        void ?{}( alarm_node_wrap(L) & this, Duration alarm, Duration period, Alarm_Callback callback, cond_lock(L) * c, info_thread(L) * i ) {
    253253                this.alarm_node{ callback, alarm, period };
    254254                this.cond = c;
     
    259259
    260260        static void timeout_handler ( alarm_node_wrap(L) & this ) with( this ) {
    261                 // This condition_variable member is called from the kernel, and therefore, cannot block, but it can spin.
     261                // This cond_lock member is called from the kernel, and therefore, cannot block, but it can spin.
    262262                lock( cond->lock __cfaabi_dbg_ctx2 );
    263263
     
    323323        //-----------------------------------------------------------------------------
    324324        // condition variable
    325         void ?{}( condition_variable(L) & this ){
     325        void ?{}( cond_lock(L) & this ){
    326326                this.lock{};
    327327                this.blocked_threads{};
     
    329329        }
    330330
    331         void ^?{}( condition_variable(L) & this ){ }
    332 
    333         static void process_popped( condition_variable(L) & this, info_thread(L) & popped ) with( this ) {
     331        void ^?{}( cond_lock(L) & this ){ }
     332
     333        static void process_popped( cond_lock(L) & this, info_thread(L) & popped ) with( this ) {
    334334                if (&popped != 0p) {
    335335                        popped.signalled = true;
     
    345345        }
    346346
    347         bool notify_one( condition_variable(L) & this ) with( this ) {
     347        bool notify_one( cond_lock(L) & this ) with( this ) {
    348348                lock( lock __cfaabi_dbg_ctx2 );
    349349                bool ret = ! isEmpty( blocked_threads );
     
    353353        }
    354354
    355         bool notify_all( condition_variable(L) & this ) with(this) {
     355        bool notify_all( cond_lock(L) & this ) with(this) {
    356356                lock( lock __cfaabi_dbg_ctx2 );
    357357                bool ret = ! isEmpty( blocked_threads );
     
    363363        }
    364364
    365         uintptr_t front( condition_variable(L) & this ) with(this) {
     365        uintptr_t front( cond_lock(L) & this ) with(this) {
    366366                return isEmpty( blocked_threads ) ? NULL : first( blocked_threads ).info;
    367367        }
    368368
    369         bool empty( condition_variable(L) & this ) with(this) {
     369        bool empty( cond_lock(L) & this ) with(this) {
    370370                lock( lock __cfaabi_dbg_ctx2 );
    371371                bool ret = isEmpty( blocked_threads );
     
    374374        }
    375375
    376         int counter( condition_variable(L) & this ) with(this) { return count; }
    377 
    378         static void enqueue_thread( condition_variable(L) & this, info_thread(L) * i ) with(this) {
     376        int counter( cond_lock(L) & this ) with(this) { return count; }
     377
     378        static void enqueue_thread( cond_lock(L) & this, info_thread(L) * i ) with(this) {
    379379                // add info_thread to waiting queue
    380380                insert_last( blocked_threads, *i );
     
    393393
    394394        // helper for wait()'s' with no timeout
    395         static void queue_info_thread( condition_variable(L) & this, info_thread(L) & i ) with(this) {
     395        static void queue_info_thread( cond_lock(L) & this, info_thread(L) & i ) with(this) {
    396396                lock( lock __cfaabi_dbg_ctx2 );
    397397                enqueue_thread( this, &i );
     
    412412
    413413        // helper for wait()'s' with a timeout
    414         static void queue_info_thread_timeout( condition_variable(L) & this, info_thread(L) & info, Duration t, Alarm_Callback callback ) with(this) {
     414        static void queue_info_thread_timeout( cond_lock(L) & this, info_thread(L) & info, Duration t, Alarm_Callback callback ) with(this) {
    415415                lock( lock __cfaabi_dbg_ctx2 );
    416416                enqueue_thread( this, &info );
     
    434434                return i.signalled;
    435435
    436         void wait( condition_variable(L) & this ) with(this) { WAIT( 0, 0p ) }
    437         void wait( condition_variable(L) & this, uintptr_t info ) with(this) { WAIT( info, 0p ) }
    438         void wait( condition_variable(L) & this, L & l  ) with(this) { WAIT( 0, &l ) }
    439         void wait( condition_variable(L) & this, L & l, uintptr_t info ) with(this) { WAIT( info, &l ) }
    440 
    441         bool wait( condition_variable(L) & this, Duration duration ) with(this) { WAIT_TIME( 0 , 0p , duration ) }
    442         bool wait( condition_variable(L) & this, uintptr_t info, Duration duration ) with(this) { WAIT_TIME( info, 0p , duration ) }
    443         bool wait( condition_variable(L) & this, L & l, Duration duration  ) with(this) { WAIT_TIME( 0 , &l , duration ) }
    444         bool wait( condition_variable(L) & this, L & l, uintptr_t info, Duration duration ) with(this) { WAIT_TIME( info, &l , duration ) }
     436        void wait( cond_lock(L) & this ) with(this) { WAIT( 0, 0p ) }
     437        void wait( cond_lock(L) & this, uintptr_t info ) with(this) { WAIT( info, 0p ) }
     438        void wait( cond_lock(L) & this, L & l  ) with(this) { WAIT( 0, &l ) }
     439        void wait( cond_lock(L) & this, L & l, uintptr_t info ) with(this) { WAIT( info, &l ) }
     440
     441        bool wait( cond_lock(L) & this, Duration duration ) with(this) { WAIT_TIME( 0 , 0p , duration ) }
     442        bool wait( cond_lock(L) & this, uintptr_t info, Duration duration ) with(this) { WAIT_TIME( info, 0p , duration ) }
     443        bool wait( cond_lock(L) & this, L & l, Duration duration  ) with(this) { WAIT_TIME( 0 , &l , duration ) }
     444        bool wait( cond_lock(L) & this, L & l, uintptr_t info, Duration duration ) with(this) { WAIT_TIME( info, &l , duration ) }
    445445
    446446        //-----------------------------------------------------------------------------
  • libcfa/src/concurrency/locks.hfa

    r1324fde r8dc8f68  
    1111// Created On       : Thu Jan 21 19:46:50 2021
    1212// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Fri Apr 25 07:14:16 2025
    14 // Update Count     : 22
     13// Last Modified On : Thu Aug 21 22:36:44 2025
     14// Update Count     : 23
    1515//
    1616
     
    797797
    798798        //-----------------------------------------------------------------------------
    799         // condition_variable
     799        // cond_lock
    800800
    801801        // The multi-tool condition variable
     
    805805        // - has shadow queue
    806806        // - can be signalled outside of critical sections with no locks held
    807         struct condition_variable {
     807        struct cond_lock {
    808808                // Spin lock used for mutual exclusion
    809809                __spinlock_t lock;
     
    816816        };
    817817
    818         void ?{}( condition_variable( L ) & this );
    819         void ^?{}( condition_variable( L ) & this );
    820 
    821         bool notify_one( condition_variable( L ) & this );
    822         bool notify_all( condition_variable( L ) & this );
    823 
    824         uintptr_t front( condition_variable( L ) & this );
    825 
    826         bool empty  ( condition_variable( L ) & this );
    827         int  counter( condition_variable( L ) & this );
    828 
    829         void wait( condition_variable( L ) & this );
    830         void wait( condition_variable( L ) & this, uintptr_t info );
    831         bool wait( condition_variable( L ) & this, Duration duration );
    832         bool wait( condition_variable( L ) & this, uintptr_t info, Duration duration );
    833 
    834         void wait( condition_variable( L ) & this, L & l );
    835         void wait( condition_variable( L ) & this, L & l, uintptr_t info );
    836         bool wait( condition_variable( L ) & this, L & l, Duration duration );
    837         bool wait( condition_variable( L ) & this, L & l, uintptr_t info, Duration duration );
     818        void ?{}( cond_lock( L ) & this );
     819        void ^?{}( cond_lock( L ) & this );
     820
     821        bool notify_one( cond_lock( L ) & this );
     822        bool notify_all( cond_lock( L ) & this );
     823
     824        uintptr_t front( cond_lock( L ) & this );
     825
     826        bool empty  ( cond_lock( L ) & this );
     827        int  counter( cond_lock( L ) & this );
     828
     829        void wait( cond_lock( L ) & this );
     830        void wait( cond_lock( L ) & this, uintptr_t info );
     831        bool wait( cond_lock( L ) & this, Duration duration );
     832        bool wait( cond_lock( L ) & this, uintptr_t info, Duration duration );
     833
     834        void wait( cond_lock( L ) & this, L & l );
     835        void wait( cond_lock( L ) & this, L & l, uintptr_t info );
     836        bool wait( cond_lock( L ) & this, L & l, Duration duration );
     837        bool wait( cond_lock( L ) & this, L & l, uintptr_t info, Duration duration );
    838838
    839839        //-----------------------------------------------------------------------------
  • libcfa/src/concurrency/mutex.cfa

    r1324fde r8dc8f68  
    1212// Created On       : Fri May 25 01:37:11 2018
    1313// Last Modified By : Peter A. Buhr
    14 // Last Modified On : Sun Feb 19 17:01:36 2023
    15 // Update Count     : 3
     14// Last Modified On : Thu Aug 21 22:35:44 2025
     15// Update Count     : 4
    1616//
    1717
     
    131131//-----------------------------------------------------------------------------
    132132// Conditions
    133 void ?{}(condition_variable & this) {
     133void ?{}(cond_lock & this) {
    134134        this.blocked_threads{};
    135135}
    136136
    137 void ^?{}(condition_variable & this) {
     137void ^?{}(cond_lock & this) {
    138138        // default
    139139}
    140140
    141 void notify_one(condition_variable & this) with(this) {
     141void notify_one(cond_lock & this) with(this) {
    142142        lock( lock __cfaabi_dbg_ctx2 );
    143143        unpark(
     
    147147}
    148148
    149 void notify_all(condition_variable & this) with(this) {
     149void notify_all(cond_lock & this) with(this) {
    150150        lock( lock __cfaabi_dbg_ctx2 );
    151151        while(this.blocked_threads) {
     
    157157}
    158158
    159 void wait(condition_variable & this) {
     159void wait(cond_lock & this) {
    160160        lock( this.lock __cfaabi_dbg_ctx2 );
    161161        append( this.blocked_threads, active_thread() );
     
    165165
    166166forall(L & | is_lock(L))
    167 void wait(condition_variable & this, L & l) {
     167void wait(cond_lock & this, L & l) {
    168168        lock( this.lock __cfaabi_dbg_ctx2 );
    169169        append( this.blocked_threads, active_thread() );
  • libcfa/src/concurrency/mutex.hfa

    r1324fde r8dc8f68  
    1212// Created On       : Fri May 25 01:24:09 2018
    1313// Last Modified By : Peter A. Buhr
    14 // Last Modified On : Thu Feb  2 11:46:08 2023
    15 // Update Count     : 2
     14// Last Modified On : Thu Aug 21 22:35:23 2025
     15// Update Count     : 3
    1616//
    1717
     
    7979// Condition variables
    8080
    81 struct condition_variable {
     81struct cond_lock {
    8282        // Spin lock used for mutual exclusion
    8383        __spinlock_t lock;
     
    8787};
    8888
    89 void ?{}(condition_variable & this) __attribute__((deprecated("use concurrency/locks.hfa instead")));
    90 void ^?{}(condition_variable & this) __attribute__((deprecated("use concurrency/locks.hfa instead")));
     89void ?{}(cond_lock & this) __attribute__((deprecated("use concurrency/locks.hfa instead")));
     90void ^?{}(cond_lock & this) __attribute__((deprecated("use concurrency/locks.hfa instead")));
    9191
    92 void notify_one(condition_variable & this) __attribute__((deprecated("use concurrency/locks.hfa instead")));
    93 void notify_all(condition_variable & this) __attribute__((deprecated("use concurrency/locks.hfa instead")));
     92void notify_one(cond_lock & this) __attribute__((deprecated("use concurrency/locks.hfa instead")));
     93void notify_all(cond_lock & this) __attribute__((deprecated("use concurrency/locks.hfa instead")));
    9494
    95 void wait(condition_variable & this) __attribute__((deprecated("use concurrency/locks.hfa instead")));
     95void wait(cond_lock & this) __attribute__((deprecated("use concurrency/locks.hfa instead")));
    9696
    9797forall(L & | is_lock(L))
    98 void wait(condition_variable & this, L & l) __attribute__((deprecated("use concurrency/locks.hfa instead")));
     98void wait(cond_lock & this, L & l) __attribute__((deprecated("use concurrency/locks.hfa instead")));
    9999
    100100//-----------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.