Changeset a76efc8
- Timestamp:
- Apr 24, 2021, 8:10:15 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- c323837, fb0be05
- Parents:
- 254ad1b
- Location:
- libcfa/src/concurrency
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/io/types.hfa
r254ad1b ra76efc8 179 179 180 180 static inline { 181 bool fulfil( io_future_t & this, __s32 result) {181 $thread * fulfil( io_future_t & this, __s32 result, bool do_unpark = true ) { 182 182 this.result = result; 183 return fulfil(this.self );183 return fulfil(this.self, do_unpark); 184 184 } 185 185 -
libcfa/src/concurrency/kernel/fwd.hfa
r254ad1b ra76efc8 219 219 // Mark as fulfilled, wake thread if needed 220 220 // return true if a thread was unparked 221 bool post(oneshot & this) {221 $thread * post(oneshot & this, bool do_unpark = true) { 222 222 struct $thread * got = __atomic_exchange_n( &this.ptr, 1p, __ATOMIC_SEQ_CST); 223 if( got == 0p ) return false;224 unpark( got );225 return true;223 if( got == 0p ) return 0p; 224 if(do_unpark) unpark( got ); 225 return got; 226 226 } 227 227 } … … 335 335 // from the server side, mark the future as fulfilled 336 336 // delete it if needed 337 bool fulfil( future_t & this) {337 $thread * fulfil( future_t & this, bool do_unpark = true ) { 338 338 for() { 339 339 struct oneshot * expected = this.ptr; … … 343 343 #pragma GCC diagnostic ignored "-Wfree-nonheap-object" 344 344 #endif 345 if( expected == 3p ) { free( &this ); return false; }345 if( expected == 3p ) { free( &this ); return 0p; } 346 346 #if defined(__GNUC__) && __GNUC__ >= 7 347 347 #pragma GCC diagnostic pop … … 355 355 struct oneshot * want = expected == 0p ? 1p : 2p; 356 356 if(__atomic_compare_exchange_n(&this.ptr, &expected, want, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) { 357 if( expected == 0p ) { /* paranoid */ verify( this.ptr == 1p); return false; }358 bool ret = post( *expected);357 if( expected == 0p ) { /* paranoid */ verify( this.ptr == 1p); return 0p; } 358 $thread * ret = post( *expected, do_unpark ); 359 359 __atomic_store_n( &this.ptr, 1p, __ATOMIC_SEQ_CST); 360 360 return ret;
Note: See TracChangeset
for help on using the changeset viewer.