Changeset ca22a7c for libcfa/src/concurrency
- Timestamp:
- Jul 18, 2023, 9:33:12 AM (17 months ago)
- Branches:
- master
- Children:
- daf4c89
- Parents:
- cb344f7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/channel.hfa
rcb344f7 rca22a7c 326 326 return retval; 327 327 } 328 328 329 /////////////////////////////////////////////////////////////////////////////////////////// 329 330 // The following is Go-style operator support for channels 330 331 /////////////////////////////////////////////////////////////////////////////////////////// 331 332 332 static inline void ? >>?( T elem, channel(T) & chan) { insert( chan, elem ); }333 static inline void ?<<?( channel(T) & chan, T elem ) { insert( chan, elem ); } 333 334 static inline void ?<<?( T & ret, channel(T) & chan ) { ret = remove( chan ); } 334 335 … … 460 461 } 461 462 462 // type used by select statement to capture a chan read as the selected operation that doesn't have a param to read to463 struct chan_read_no_ret {464 T ret;465 chan_read( T ) cr;466 };467 __CFA_SELECT_GET_TYPE( chan_read_no_ret(T) );468 469 static inline void ?{}( chan_read_no_ret(T) & this, channel(T) & chan ) {470 this.cr{ chan, this.ret };471 }472 static inline chan_read_no_ret(T) remove( channel(T) & chan ) { chan_read_no_ret(T) cr{ chan }; return cr; }473 static inline bool register_select( chan_read_no_ret(T) & this, select_node & node ) { return register_select( this.cr, node ); }474 static inline bool unregister_select( chan_read_no_ret(T) & this, select_node & node ) { return unregister_select( this.cr, node ); }475 static inline bool on_selected( chan_read_no_ret(T) & this, select_node & node ) { return on_selected( this.cr, node ); }476 477 463 // type used by select statement to capture a chan write as the selected operation 478 464 struct chan_write { … … 486 472 memcpy( (void *)&cw.elem, (void *)&elem, sizeof(T) ); 487 473 } 488 static inline chan_write(T) ? >>?( T elem, channel(T) & chan) { chan_write(T) cw{ chan, elem }; return cw; }474 static inline chan_write(T) ?<<?( channel(T) & chan, T elem ) { chan_write(T) cw{ chan, elem }; return cw; } 489 475 static inline chan_write(T) insert( T elem, channel(T) & chan) { chan_write(T) cw{ chan, elem }; return cw; } 490 476
Note: See TracChangeset
for help on using the changeset viewer.