Changes in libcfa/src/concurrency/invoke.h [ab5baab:e84ab3d]
- File:
-
- 1 edited
-
libcfa/src/concurrency/invoke.h (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/invoke.h
rab5baab re84ab3d 20 20 21 21 #ifdef __cforall 22 #include "containers/list.hfa" 22 23 extern "C" { 23 24 #endif … … 70 71 enum __Coroutine_State { Halted, Start, Primed, Blocked, Ready, Active, Cancelled, Halting }; 71 72 72 struct $coroutine{73 struct coroutine$ { 73 74 // context that is switch during a __cfactx_switch 74 75 struct __stack_context_t context; … … 84 85 85 86 // first coroutine to resume this one 86 struct $coroutine* starter;87 struct coroutine$ * starter; 87 88 88 89 // last coroutine to resume this one 89 struct $coroutine* last;90 struct coroutine$ * last; 90 91 91 92 // If non-null stack must be unwound with this exception … … 94 95 }; 95 96 // Wrapper for gdb 96 struct cfathread_coroutine_t { struct $coroutinedebug; };97 98 static inline struct __stack_t * __get_stack( struct $coroutine* cor ) {97 struct cfathread_coroutine_t { struct coroutine$ debug; }; 98 99 static inline struct __stack_t * __get_stack( struct coroutine$ * cor ) { 99 100 return (struct __stack_t*)(((uintptr_t)cor->stack.storage) & ((uintptr_t)-2)); 100 101 } … … 109 110 }; 110 111 111 struct $monitor{112 struct monitor$ { 112 113 // spinlock to protect internal data 113 114 struct __spinlock_t lock; 114 115 115 116 // current owner of the monitor 116 struct $thread* owner;117 struct thread$ * owner; 117 118 118 119 // queue of threads that are blocked waiting for the monitor 119 __queue_t(struct $thread) entry_queue;120 __queue_t(struct thread$) entry_queue; 120 121 121 122 // stack of conditions to run next once we exit the monitor … … 132 133 }; 133 134 // Wrapper for gdb 134 struct cfathread_monitor_t { struct $monitordebug; };135 struct cfathread_monitor_t { struct monitor$ debug; }; 135 136 136 137 struct __monitor_group_t { 137 138 // currently held monitors 138 __cfa_anonymous_object( __small_array_t( $monitor*) );139 __cfa_anonymous_object( __small_array_t(monitor$*) ); 139 140 140 141 // last function that acquired monitors … … 145 146 // instrusive link field for threads 146 147 struct __thread_desc_link { 147 struct $thread* next;148 struct thread$ * next; 148 149 volatile unsigned long long ts; 149 150 }; 150 151 151 struct $thread{152 struct thread$ { 152 153 // Core threading fields 153 154 // context that is switch during a __cfactx_switch … … 178 179 179 180 // coroutine body used to store context 180 struct $coroutineself_cor;181 struct coroutine$ self_cor; 181 182 182 183 // current active context 183 struct $coroutine* curr_cor;184 struct coroutine$ * curr_cor; 184 185 185 186 // monitor body used for mutual exclusion 186 struct $monitorself_mon;187 struct monitor$ self_mon; 187 188 188 189 // pointer to monitor with sufficient lifetime for current monitors 189 struct $monitor* self_mon_p;190 struct monitor$ * self_mon_p; 190 191 191 192 // monitors currently held by this thread … … 194 195 // used to put threads on user data structures 195 196 struct { 196 struct $thread* next;197 struct $thread* back;197 struct thread$ * next; 198 struct thread$ * back; 198 199 } seqable; 199 200 201 // used to put threads on dlist data structure 202 __cfa_dlink(thread$); 203 200 204 struct { 201 struct $thread* next;202 struct $thread* prev;205 struct thread$ * next; 206 struct thread$ * prev; 203 207 } node; 204 208 … … 209 213 #endif 210 214 }; 215 #ifdef __cforall 216 P9_EMBEDDED( thread$, dlink(thread$) ) 217 #endif 211 218 // Wrapper for gdb 212 struct cfathread_thread_t { struct $threaddebug; };219 struct cfathread_thread_t { struct thread$ debug; }; 213 220 214 221 #ifdef __CFA_DEBUG__ 215 void __cfaabi_dbg_record_thrd( $thread& this, bool park, const char prev_name[]);222 void __cfaabi_dbg_record_thrd(thread$ & this, bool park, const char prev_name[]); 216 223 #else 217 224 #define __cfaabi_dbg_record_thrd(x, y, z) … … 221 228 extern "Cforall" { 222 229 223 static inline $thread *& get_next( $thread& this ) __attribute__((const)) {230 static inline thread$ *& get_next( thread$ & this ) __attribute__((const)) { 224 231 return this.link.next; 225 232 } 226 233 227 static inline [ $thread *&, $thread *& ] __get( $thread& this ) __attribute__((const)) {234 static inline [thread$ *&, thread$ *& ] __get( thread$ & this ) __attribute__((const)) { 228 235 return this.node.[next, prev]; 229 236 } 230 237 231 static inline $thread * volatile & ?`next ( $thread* this ) __attribute__((const)) {238 static inline thread$ * volatile & ?`next ( thread$ * this ) __attribute__((const)) { 232 239 return this->seqable.next; 233 240 } 234 241 235 static inline $thread *& Back( $thread* this ) __attribute__((const)) {242 static inline thread$ *& Back( thread$ * this ) __attribute__((const)) { 236 243 return this->seqable.back; 237 244 } 238 245 239 static inline $thread *& Next( $thread* this ) __attribute__((const)) {240 return this->seqable.next;241 } 242 243 static inline bool listed( $thread* this ) {246 static inline thread$ *& Next( thread$ * this ) __attribute__((const)) { 247 return this->seqable.next; 248 } 249 250 static inline bool listed( thread$ * this ) { 244 251 return this->seqable.next != 0p; 245 252 } … … 251 258 } 252 259 253 static inline void ?{}(__monitor_group_t & this, struct $monitor** data, __lock_size_t size, fptr_t func) {260 static inline void ?{}(__monitor_group_t & this, struct monitor$ ** data, __lock_size_t size, fptr_t func) { 254 261 (this.data){data}; 255 262 (this.size){size};
Note:
See TracChangeset
for help on using the changeset viewer.