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