Changeset 8dc8f68 for libcfa/src/concurrency/locks.cfa
- Timestamp:
- Aug 21, 2025, 11:14:05 PM (5 weeks ago)
- Branches:
- master
- Children:
- 31be464
- Parents:
- 1324fde
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/locks.cfa
r1324fde r8dc8f68 246 246 struct alarm_node_wrap { 247 247 alarm_node_t alarm_node; 248 cond ition_variable(L) * cond;248 cond_lock(L) * cond; 249 249 info_thread(L) * info_thd; 250 250 }; 251 251 252 void ?{}( alarm_node_wrap(L) & this, Duration alarm, Duration period, Alarm_Callback callback, cond ition_variable(L) * c, info_thread(L) * i ) {252 void ?{}( alarm_node_wrap(L) & this, Duration alarm, Duration period, Alarm_Callback callback, cond_lock(L) * c, info_thread(L) * i ) { 253 253 this.alarm_node{ callback, alarm, period }; 254 254 this.cond = c; … … 259 259 260 260 static void timeout_handler ( alarm_node_wrap(L) & this ) with( this ) { 261 // This cond ition_variablemember is called from the kernel, and therefore, cannot block, but it can spin.261 // This cond_lock member is called from the kernel, and therefore, cannot block, but it can spin. 262 262 lock( cond->lock __cfaabi_dbg_ctx2 ); 263 263 … … 323 323 //----------------------------------------------------------------------------- 324 324 // condition variable 325 void ?{}( cond ition_variable(L) & this ){325 void ?{}( cond_lock(L) & this ){ 326 326 this.lock{}; 327 327 this.blocked_threads{}; … … 329 329 } 330 330 331 void ^?{}( cond ition_variable(L) & this ){ }332 333 static void process_popped( cond ition_variable(L) & this, info_thread(L) & popped ) with( this ) {331 void ^?{}( cond_lock(L) & this ){ } 332 333 static void process_popped( cond_lock(L) & this, info_thread(L) & popped ) with( this ) { 334 334 if (&popped != 0p) { 335 335 popped.signalled = true; … … 345 345 } 346 346 347 bool notify_one( cond ition_variable(L) & this ) with( this ) {347 bool notify_one( cond_lock(L) & this ) with( this ) { 348 348 lock( lock __cfaabi_dbg_ctx2 ); 349 349 bool ret = ! isEmpty( blocked_threads ); … … 353 353 } 354 354 355 bool notify_all( cond ition_variable(L) & this ) with(this) {355 bool notify_all( cond_lock(L) & this ) with(this) { 356 356 lock( lock __cfaabi_dbg_ctx2 ); 357 357 bool ret = ! isEmpty( blocked_threads ); … … 363 363 } 364 364 365 uintptr_t front( cond ition_variable(L) & this ) with(this) {365 uintptr_t front( cond_lock(L) & this ) with(this) { 366 366 return isEmpty( blocked_threads ) ? NULL : first( blocked_threads ).info; 367 367 } 368 368 369 bool empty( cond ition_variable(L) & this ) with(this) {369 bool empty( cond_lock(L) & this ) with(this) { 370 370 lock( lock __cfaabi_dbg_ctx2 ); 371 371 bool ret = isEmpty( blocked_threads ); … … 374 374 } 375 375 376 int counter( cond ition_variable(L) & this ) with(this) { return count; }377 378 static void enqueue_thread( cond ition_variable(L) & this, info_thread(L) * i ) with(this) {376 int counter( cond_lock(L) & this ) with(this) { return count; } 377 378 static void enqueue_thread( cond_lock(L) & this, info_thread(L) * i ) with(this) { 379 379 // add info_thread to waiting queue 380 380 insert_last( blocked_threads, *i ); … … 393 393 394 394 // helper for wait()'s' with no timeout 395 static void queue_info_thread( cond ition_variable(L) & this, info_thread(L) & i ) with(this) {395 static void queue_info_thread( cond_lock(L) & this, info_thread(L) & i ) with(this) { 396 396 lock( lock __cfaabi_dbg_ctx2 ); 397 397 enqueue_thread( this, &i ); … … 412 412 413 413 // helper for wait()'s' with a timeout 414 static void queue_info_thread_timeout( cond ition_variable(L) & this, info_thread(L) & info, Duration t, Alarm_Callback callback ) with(this) {414 static void queue_info_thread_timeout( cond_lock(L) & this, info_thread(L) & info, Duration t, Alarm_Callback callback ) with(this) { 415 415 lock( lock __cfaabi_dbg_ctx2 ); 416 416 enqueue_thread( this, &info ); … … 434 434 return i.signalled; 435 435 436 void wait( cond ition_variable(L) & this ) with(this) { WAIT( 0, 0p ) }437 void wait( cond ition_variable(L) & this, uintptr_t info ) with(this) { WAIT( info, 0p ) }438 void wait( cond ition_variable(L) & this, L & l ) with(this) { WAIT( 0, &l ) }439 void wait( cond ition_variable(L) & this, L & l, uintptr_t info ) with(this) { WAIT( info, &l ) }440 441 bool wait( cond ition_variable(L) & this, Duration duration ) with(this) { WAIT_TIME( 0 , 0p , duration ) }442 bool wait( cond ition_variable(L) & this, uintptr_t info, Duration duration ) with(this) { WAIT_TIME( info, 0p , duration ) }443 bool wait( cond ition_variable(L) & this, L & l, Duration duration ) with(this) { WAIT_TIME( 0 , &l , duration ) }444 bool wait( cond ition_variable(L) & this, L & l, uintptr_t info, Duration duration ) with(this) { WAIT_TIME( info, &l , duration ) }436 void wait( cond_lock(L) & this ) with(this) { WAIT( 0, 0p ) } 437 void wait( cond_lock(L) & this, uintptr_t info ) with(this) { WAIT( info, 0p ) } 438 void wait( cond_lock(L) & this, L & l ) with(this) { WAIT( 0, &l ) } 439 void wait( cond_lock(L) & this, L & l, uintptr_t info ) with(this) { WAIT( info, &l ) } 440 441 bool wait( cond_lock(L) & this, Duration duration ) with(this) { WAIT_TIME( 0 , 0p , duration ) } 442 bool wait( cond_lock(L) & this, uintptr_t info, Duration duration ) with(this) { WAIT_TIME( info, 0p , duration ) } 443 bool wait( cond_lock(L) & this, L & l, Duration duration ) with(this) { WAIT_TIME( 0 , &l , duration ) } 444 bool wait( cond_lock(L) & this, L & l, uintptr_t info, Duration duration ) with(this) { WAIT_TIME( info, &l , duration ) } 445 445 446 446 //-----------------------------------------------------------------------------
Note:
See TracChangeset
for help on using the changeset viewer.