Ignore:
File:
1 edited

Legend:

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

    r6f774be r70a4ed5  
    9191    // For unregistering a select stmt on a selectable concurrency primitive
    9292    // If true is returned then the corresponding code block is run (only in non-special OR case and only if node status is not RUN)
    93     bool unregister_select( T &, select_node &  );
     93    bool unregister_select( T &, select_node & );
    9494
    9595    // This routine is run on the selecting thread prior to executing the statement corresponding to the select_node
    9696    //    passed as an arg to this routine
    9797    // If on_selected returns false, the statement is not run, if it returns true it is run.
    98     bool on_selected( T &, select_node & );
     98    void on_selected( T &, select_node & );
    9999};
    100100
     
    102102// Waituntil Helpers
    103103//=============================================================================================
    104 
    105 static inline void __make_select_node_unsat( select_node & this ) with( this ) {
    106     __atomic_store_n( clause_status, __SELECT_UNSAT, __ATOMIC_SEQ_CST );
    107 }
    108 static inline void __make_select_node_sat( select_node & this ) with( this ) {
    109     __atomic_store_n( clause_status, __SELECT_SAT, __ATOMIC_SEQ_CST );
    110 }
    111104
    112105// used for the 2-stage avail needed by the special OR case
     
    123116}
    124117
    125 // used for the 2-stage avail by the thread who owns a pending node
    126 static inline bool __pending_set_other( select_node & other, select_node & mine, unsigned long int val ) with( other ) {
    127     /* paranoid */ verify( park_counter == 0p );
    128     /* paranoid */ verify( clause_status != 0p );
    129 
    130     unsigned long int cmp_status = __SELECT_UNSAT;
    131     while( !__atomic_compare_exchange_n( clause_status, &cmp_status, val, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST ) ) {
    132         if ( cmp_status != __SELECT_PENDING )
    133             return false;
    134 
    135         // toggle current status flag to avoid starvation/deadlock
    136         __make_select_node_unsat( mine );
    137         cmp_status = __SELECT_UNSAT;
    138         if ( !__atomic_compare_exchange_n( mine.clause_status, &cmp_status, __SELECT_PENDING, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST ) )
    139             return false;
    140         cmp_status = __SELECT_UNSAT;
    141     }
    142     return true;
     118static inline void __make_select_node_unsat( select_node & this ) with( this ) {
     119    __atomic_store_n( clause_status, __SELECT_UNSAT, __ATOMIC_SEQ_CST );
     120}
     121static inline void __make_select_node_sat( select_node & this ) with( this ) {
     122    __atomic_store_n( clause_status, __SELECT_SAT, __ATOMIC_SEQ_CST );
    143123}
    144124
     
    208188bool register_select( select_timeout_node & this, select_node & node );
    209189bool unregister_select( select_timeout_node & this, select_node & node );
    210 bool on_selected( select_timeout_node & this, select_node & node );
     190void on_selected( select_timeout_node & this, select_node & node );
    211191
    212192// Gateway routines to waituntil on duration
Note: See TracChangeset for help on using the changeset viewer.