Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/containers/lockfree.hfa

    re8b8e65 r88ac843e  
    142142
    143143        static inline void ?{}(poison_list(T) & this) { this.head = 0p; }
    144         static inline bool is_poisoned( const poison_list(T) & this ) { return 1p == this.head; }
    145144
    146145        static inline forall(| { T * volatile & ?`next ( T * ); })
     
    148147                // Adds an element to the list
    149148                // Multi-Thread Safe, Lock-Free
    150                 bool push(poison_list(T) & this, T * elem) __attribute__((artificial));
    151                 bool push(poison_list(T) & this, T * elem) {
     149                T * push(poison_list(T) & this, T * elem) __attribute__((artificial));
     150                T * push(poison_list(T) & this, T * elem) {
    152151                        /* paranoid */ verify(0p == (elem`next));
    153152                        __atomic_store_n( &elem`next, (T*)1p, __ATOMIC_RELAXED );
     
    157156                        for() {
    158157                                // check if it's poisoned
    159                                 if(expected == 1p) return false;
     158                                if(expected == 1p) return 0p;
    160159
    161160                                // try to CAS the elem in
     
    163162                                        // We managed to exchange in, we are done
    164163
    165                                         // We should never succeed the CAS if it's poisonned and the elem should be 1p.
    166                                         /* paranoid */ verify( expected  != 1p );
    167                                         /* paranoid */ verify( elem`next == 1p );
     164                                        // We should never succeed the CAS if it's poisonned.
     165                                        /* paranoid */ verify( expected != 1p );
    168166
    169167                                        // If we aren't the first, we need to tell the person before us
    170168                                        // No need to
    171169                                        elem`next = expected;
    172                                         return true;
     170                                        return expected;
    173171                                }
    174172                        }
     
    192190                T * poison(poison_list(T) & this) {
    193191                        T * ret = __atomic_exchange_n( &this.head, (T*)1p, __ATOMIC_SEQ_CST );
    194                         /* paranoid */ verifyf( ret != (T*)1p, "Poison list %p poisoned more than once!", &this );
     192                        /* paranoid */ verify( ret != (T*)1p );
    195193                        return ret;
    196194                }
Note: See TracChangeset for help on using the changeset viewer.