- Timestamp:
- May 15, 2023, 1:16:20 PM (22 months ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- 100d12d4
- Parents:
- c0ec8b6
- Location:
- libcfa/src/concurrency
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified libcfa/src/concurrency/select.hfa ¶
rc0ec8b6 re23b3ce 1 // 2 // Cforall Version 1.0.0 Copyright (C) 2021 University of Waterloo 3 // 4 // The contents of this file are covered under the licence agreement in the 5 // file "LICENCE" distributed with Cforall. 6 // 7 // channel.hfa -- LIBCFATHREAD 8 // Runtime locks that used with the runtime thread system. 9 // 10 // Author : Colby Alexander Parsons 11 // Created On : Thu Jan 21 19:46:50 2023 12 // Last Modified By : 13 // Last Modified On : 14 // Update Count : 15 // 16 1 17 #pragma once 2 18 3 19 #include "containers/list.hfa" 4 // #include "alarm.hfa" 5 #include "stdint.h" 20 #include "alarm.hfa" 6 21 #include "kernel.hfa" 7 22 #include "time.hfa" … … 14 29 static const unsigned long int __SELECT_SAT = 2; 15 30 static const unsigned long int __SELECT_RUN = 3; 16 17 31 18 32 // these are used inside the compiler to aid in code generation … … 105 119 __atomic_store_n( clause_status, __SELECT_UNSAT, __ATOMIC_SEQ_CST ); 106 120 } 121 static inline void __make_select_node_sat( select_node & this ) with( this ) { 122 __atomic_store_n( clause_status, __SELECT_SAT, __ATOMIC_SEQ_CST ); 123 } 107 124 108 125 static inline bool __make_select_node_pending( select_node & this ) with( this ) { … … 116 133 if( !park_counter ) 117 134 return __mark_select_node( this, (unsigned long int)&this ); 118 // return *clause_status == 0119 // && __atomic_compare_exchange_n( clause_status, &cmp_status, (unsigned long int)&this, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST ); // OR specific case where race was won120 135 121 136 unsigned long int cmp_status = __SELECT_UNSAT; … … 135 150 while ( !queue`isEmpty ) { 136 151 // if node not a special OR case or if we win the special OR case race break 137 if ( !queue`first.clause_status || queue`first.park_counter || __make_select_node_available( queue`first ) ) { return true; } 152 if ( !queue`first.clause_status || queue`first.park_counter || __make_select_node_available( queue`first ) ) 153 return true; 138 154 // otherwise we lost the special OR race so discard node 139 155 try_pop_front( queue ); … … 160 176 } 161 177 178 // waituntil ( timeout( ... ) ) support 179 struct select_timeout_node { 180 alarm_node_t a_node; 181 select_node * s_node; 182 }; 183 void ?{}( select_timeout_node & this, Duration duration, Alarm_Callback callback ); 184 void ^?{}( select_timeout_node & this ); 185 void timeout_handler_select_cast( alarm_node_t & node ); 162 186 187 // Selectable trait routines 188 bool register_select( select_timeout_node & this, select_node & node ); 189 bool unregister_select( select_timeout_node & this, select_node & node ); 190 bool on_selected( select_timeout_node & this, select_node & node ); 191 192 // Gateway routines to waituntil on duration 193 select_timeout_node timeout( Duration duration ); 194 select_timeout_node sleep( Duration duration );
Note: See TracChangeset
for help on using the changeset viewer.