Changes in / [a41e87b:f621e43f]
- Files:
-
- 4 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/locks.hfa
ra41e87b rf621e43f 82 82 83 83 // 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 85 88 bool tryP(BinaryBenaphore & this) { 86 89 ssize_t c = this.counter; … … 115 118 static inline void ?{}(ThreadBenaphore & this, one_t ) { (this.ben){ 1 }; } 116 119 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 ); }120 static inline bool P(ThreadBenaphore & this) { return P(this.ben) ? false : P(this.sem); } 121 static inline bool P(ThreadBenaphore & this, $thread * t) { return P(this.ben) ? false : P(this.sem, t ); } 119 122 static inline bool tryP(ThreadBenaphore & this) { return tryP(this.ben); } 120 123 static inline bool P(ThreadBenaphore & this, bool wait) { return wait ? P(this) : tryP(this); } 121 124 122 125 static inline $thread * V(ThreadBenaphore & this, const bool doUnpark = true) { 123 //if (V(this.ben)) return 0p;126 if (V(this.ben)) return 0p; 124 127 return V(this.sem, doUnpark); 125 128 } -
tests/concurrent/spinaphore.cfa
ra41e87b rf621e43f 36 36 this.sum = 0; 37 37 for(num_blocks) { 38 // sout | "b P" | me;39 38 P(sem); 40 39 if(((thread&)this).seqable.next != 0p) sout | "Link not invalidated"; 41 // sout | "a P" | me;42 40 } 43 41 } … … 58 56 this.sum += (unsigned)b; 59 57 unpark(t); 60 // sout | "a V" | t;61 58 yield(random(10)); 62 59 }
Note: See TracChangeset
for help on using the changeset viewer.