Changeset 63364d8 for libcfa/src/concurrency/coroutine.hfa
- Timestamp:
- May 9, 2019, 4:47:28 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- b038fe4
- Parents:
- f019069
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/coroutine.hfa
rf019069 r63364d8 68 68 69 69 extern void CtxSwitch( struct __stack_context_t * from, struct __stack_context_t * to ) asm ("CtxSwitch"); 70 extern void CtxStore ( struct __stack_context_t * from, fptr_t callback ) asm ("CtxStore");71 70 } 72 71 … … 171 170 } 172 171 173 __attribute__((noreturn)) void __suspend_callback(void *, fptr_t call);174 175 static inline void suspend_then(fptr_t call) {176 // optimization : read TLS once and reuse it177 // Safety note: this is preemption safe since if178 // preemption occurs after this line, the pointer179 // will also migrate which means this value will180 // stay in syn with the TLS181 coroutine_desc * src = TL_GET( this_thread )->curr_cor;182 183 assertf( src->last != 0,184 "Attempt to suspend coroutine \"%.256s\" (%p) that has never been resumed.\n"185 "Possible cause is a suspend executed in a member called by a coroutine user rather than by the coroutine main.",186 src->name, src );187 assertf( src->last->state != Halted,188 "Attempt by coroutine \"%.256s\" (%p) to suspend back to terminated coroutine \"%.256s\" (%p).\n"189 "Possible cause is terminated coroutine's main routine has already returned.",190 src->name, src, src->last->name, src->last );191 192 src->state = PreInactive;193 194 // context switch to specified coroutine195 assert( src->context.SP );196 197 CtxStore( &src->context, call );198 // when CtxStore returns we are back in the src coroutine199 200 // set state of new coroutine to active201 src->state = Active;202 203 if( unlikely(src->cancellation != NULL) ) {204 _CtxCoroutine_Unwind(src->cancellation, src);205 }206 207 return;208 }209 210 172 // Local Variables: // 211 173 // mode: c //
Note: See TracChangeset
for help on using the changeset viewer.