Changeset 0aef549 for libcfa/src/concurrency/channel.hfa
- Timestamp:
- Jun 1, 2023, 12:01:05 PM (13 months ago)
- Branches:
- ast-experimental, master
- Children:
- 4897ffa
- Parents:
- ac5d22f (diff), 8421d3f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/channel.hfa
rac5d22f r0aef549 341 341 } 342 342 343 // special case of __handle_waituntil_OR, that does some work to avoid starvation/deadlock case 344 static inline bool __handle_pending( dlist( select_node ) & queue, select_node & mine ) { 345 while ( !queue`isEmpty ) { 346 // if node not a special OR case or if we win the special OR case race break 347 if ( !queue`first.clause_status || queue`first.park_counter || __pending_set_other( queue`first, mine, ((unsigned long int)(&(queue`first))) ) ) 348 return true; 349 350 // our node lost the race when toggling in __pending_set_other 351 if ( *mine.clause_status != __SELECT_PENDING ) 352 return false; 353 354 // otherwise we lost the special OR race so discard node 355 try_pop_front( queue ); 356 } 357 return false; 358 } 359 343 360 // type used by select statement to capture a chan read as the selected operation 344 361 struct chan_read { … … 374 391 return false; 375 392 } 376 377 if ( __handle_ waituntil_OR( prods) ) {393 394 if ( __handle_pending( prods, node ) ) { 378 395 __prods_handoff( chan, ret ); 379 396 __make_select_node_sat( node ); // need to to mark SAT now that we know operation is done or else threads could get stuck in __mark_select_node … … 381 398 return true; 382 399 } 383 __make_select_node_unsat( node ); 400 if ( *node.clause_status == __SELECT_PENDING ) 401 __make_select_node_unsat( node ); 384 402 } 385 403 // check if we can complete operation. If so race to establish winner in special OR case … … 463 481 return false; 464 482 } 465 466 if ( __handle_ waituntil_OR( cons) ) {483 484 if ( __handle_pending( cons, node ) ) { 467 485 __cons_handoff( chan, elem ); 468 486 __make_select_node_sat( node ); // need to to mark SAT now that we know operation is done or else threads could get stuck in __mark_select_node … … 470 488 return true; 471 489 } 472 __make_select_node_unsat( node ); 490 if ( *node.clause_status == __SELECT_PENDING ) 491 __make_select_node_unsat( node ); 473 492 } 474 493 // check if we can complete operation. If so race to establish winner in special OR case
Note: See TracChangeset
for help on using the changeset viewer.