Changeset e2f601f for libcfa/src/executor.cfa
- Timestamp:
- May 13, 2021, 3:49:30 PM (3 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- aff7e86, c457dc41
- Parents:
- 8cd5434 (diff), 69914cbc (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/executor.cfa
r8cd5434 re2f601f 7 7 #include <containers/list.hfa> 8 8 9 forall( T & | $dlistable(T, T) ) {9 forall( T &, TLink& = dlink(T) | embedded(T, TLink, dlink(T)) ) { 10 10 monitor Buffer { // unbounded buffer 11 dlist( T, T ) queue;// unbounded list of work requests11 dlist( T, TLink ) queue; // unbounded list of work requests 12 12 condition delay; 13 13 }; // Buffer 14 14 15 void insert( Buffer(T ) & mutex buf, T * elem ) with(buf) {16 dlist( T, T ) * qptr = &queue;// workaround https://cforall.uwaterloo.ca/trac/ticket/16615 void insert( Buffer(T, TLink) & mutex buf, T * elem ) with(buf) { 16 dlist( T, TLink ) * qptr = &queue; // workaround https://cforall.uwaterloo.ca/trac/ticket/166 17 17 insert_last( *qptr, *elem ); // insert element into buffer 18 18 signal( delay ); // restart 19 19 } // insert 20 20 21 T * remove( Buffer(T ) & mutex buf ) with(buf) {22 dlist( T, T ) * qptr = &queue;// workaround https://cforall.uwaterloo.ca/trac/ticket/16623 // if ( (*qptr)`is _empty ) wait( delay );// no request to process ? => wait24 if ( (*qptr)`is _empty ) return 0p;// no request to process ? => wait25 return & pop_first( *qptr );21 T * remove( Buffer(T, TLink) & mutex buf ) with(buf) { 22 dlist( T, TLink ) * qptr = &queue; // workaround https://cforall.uwaterloo.ca/trac/ticket/166 23 // if ( (*qptr)`isEmpty ) wait( delay ); // no request to process ? => wait 24 if ( (*qptr)`isEmpty ) return 0p; // no request to process ? => wait 25 return &try_pop_front( *qptr ); 26 26 } // remove 27 27 } // forall … … 29 29 struct WRequest { // client request, no return 30 30 void (* action)( void ); 31 DLISTED_MGD_IMPL_IN(WRequest)31 inline dlink(WRequest); 32 32 }; // WRequest 33 DLISTED_MGD_IMPL_OUT(WRequest)33 P9_EMBEDDED(WRequest, dlink(WRequest)) 34 34 35 35 void ?{}( WRequest & req ) with(req) { action = 0; }
Note: See TracChangeset
for help on using the changeset viewer.