Changes in / [a41e87b:f621e43f]


Ignore:
Files:
4 added
2 edited

Legend:

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

    ra41e87b rf621e43f  
    8282
    8383        // returns true if no blocking needed
    84         bool P(BinaryBenaphore & this) { return __atomic_fetch_sub(&this.counter, 1, __ATOMIC_SEQ_CST) > 0; }
     84        bool P(BinaryBenaphore & this) {
     85                return __atomic_fetch_sub(&this.counter, 1, __ATOMIC_SEQ_CST) > 0;
     86        }
     87
    8588        bool tryP(BinaryBenaphore & this) {
    8689                ssize_t c = this.counter;
     
    115118static inline void ?{}(ThreadBenaphore & this, one_t ) { (this.ben){ 1 }; }
    116119
    117 static inline bool P(ThreadBenaphore & this)              { return /* P(this.ben) ? false : */ P(this.sem); }
    118 static inline bool P(ThreadBenaphore & this, $thread * t) { return /* P(this.ben) ? false : */ P(this.sem, t ); }
     120static inline bool P(ThreadBenaphore & this)              { return P(this.ben) ? false : P(this.sem); }
     121static inline bool P(ThreadBenaphore & this, $thread * t) { return P(this.ben) ? false : P(this.sem, t ); }
    119122static inline bool tryP(ThreadBenaphore & this)           { return tryP(this.ben); }
    120123static inline bool P(ThreadBenaphore & this, bool wait)   { return wait ? P(this) : tryP(this); }
    121124
    122125static inline $thread * V(ThreadBenaphore & this, const bool doUnpark = true) {
    123         // if (V(this.ben)) return 0p;
     126        if (V(this.ben)) return 0p;
    124127        return V(this.sem, doUnpark);
    125128}
  • tests/concurrent/spinaphore.cfa

    ra41e87b rf621e43f  
    3636        this.sum = 0;
    3737        for(num_blocks) {
    38                 // sout | "b P" | me;
    3938                P(sem);
    4039                if(((thread&)this).seqable.next != 0p) sout | "Link not invalidated";
    41                 // sout | "a P" | me;
    4240        }
    4341}
     
    5856                this.sum += (unsigned)b;
    5957                unpark(t);
    60                 // sout | "a V" | t;
    6158                yield(random(10));
    6259        }
Note: See TracChangeset for help on using the changeset viewer.