- File:
-
- 1 edited
-
libcfa/src/concurrency/locks.cfa (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/locks.cfa
r7f958c4 r708ae38 220 220 221 221 //----------------------------------------------------------------------------- 222 // Synchronization Locks222 // condition variable 223 223 forall(L & | is_blocking_lock(L)) { 224 224 225 //-----------------------------------------------------------------------------226 // condition variable227 225 void ?{}( condition_variable(L) & this ){ 228 226 this.lock{}; … … 339 337 bool wait( condition_variable(L) & this, L & l, Duration duration ) with(this) { WAIT_TIME( 0 , &l , duration ) } 340 338 bool wait( condition_variable(L) & this, L & l, uintptr_t info, Duration duration ) with(this) { WAIT_TIME( info, &l , duration ) } 341 342 //-----------------------------------------------------------------------------343 // fast_cond_var344 void ?{}( fast_cond_var(L) & this ){345 this.blocked_threads{};346 #ifdef __CFA_DEBUG__347 this.lock_used = 0p;348 #endif349 }350 void ^?{}( fast_cond_var(L) & this ){ }351 352 bool notify_one( fast_cond_var(L) & this ) with(this) {353 bool ret = ! blocked_threads`isEmpty;354 if ( ret ) {355 info_thread(L) & popped = try_pop_front( blocked_threads );356 on_notify(*popped.lock, popped.t);357 }358 return ret;359 }360 bool notify_all( fast_cond_var(L) & this ) with(this) {361 bool ret = ! blocked_threads`isEmpty;362 while( ! blocked_threads`isEmpty ) {363 info_thread(L) & popped = try_pop_front( blocked_threads );364 on_notify(*popped.lock, popped.t);365 }366 return ret;367 }368 369 uintptr_t front( fast_cond_var(L) & this ) with(this) { return blocked_threads`isEmpty ? NULL : blocked_threads`first.info; }370 bool empty ( fast_cond_var(L) & this ) with(this) { return blocked_threads`isEmpty; }371 372 void wait( fast_cond_var(L) & this, L & l ) {373 wait( this, l, 0 );374 }375 376 void wait( fast_cond_var(L) & this, L & l, uintptr_t info ) with(this) {377 // brand cond lock with lock378 #ifdef __CFA_DEBUG__379 if ( lock_used == 0p ) lock_used = &l;380 else { assert(lock_used == &l); }381 #endif382 info_thread( L ) i = { active_thread(), info, &l };383 insert_last( blocked_threads, i );384 size_t recursion_count = on_wait( *i.lock );385 park( );386 on_wakeup(*i.lock, recursion_count);387 }388 339 } 389 340
Note:
See TracChangeset
for help on using the changeset viewer.