- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/coroutine.hfa
r427854b rac2b598 46 46 //----------------------------------------------------------------------------- 47 47 // Public coroutine API 48 static inline void suspend(void); 49 50 forall(dtype T | is_coroutine(T)) 51 static inline T & resume(T & cor); 52 48 53 forall(dtype T | is_coroutine(T)) 49 54 void prime(T & cor); … … 91 96 92 97 // Suspend implementation inlined for performance 93 extern "C" { 94 static inline void __cfactx_suspend(void) { 95 // optimization : read TLS once and reuse it 96 // Safety note: this is preemption safe since if 97 // preemption occurs after this line, the pointer 98 // will also migrate which means this value will 99 // stay in syn with the TLS 100 $coroutine * src = TL_GET( this_thread )->curr_cor; 98 static inline void suspend(void) { 99 // optimization : read TLS once and reuse it 100 // Safety note: this is preemption safe since if 101 // preemption occurs after this line, the pointer 102 // will also migrate which means this value will 103 // stay in syn with the TLS 104 $coroutine * src = TL_GET( this_thread )->curr_cor; 101 105 102 103 104 105 106 107 108 109 106 assertf( src->last != 0, 107 "Attempt to suspend coroutine \"%.256s\" (%p) that has never been resumed.\n" 108 "Possible cause is a suspend executed in a member called by a coroutine user rather than by the coroutine main.", 109 src->name, src ); 110 assertf( src->last->state != Halted, 111 "Attempt by coroutine \"%.256s\" (%p) to suspend back to terminated coroutine \"%.256s\" (%p).\n" 112 "Possible cause is terminated coroutine's main routine has already returned.", 113 src->name, src, src->last->name, src->last ); 110 114 111 $ctx_switch( src, src->last ); 112 } 115 $ctx_switch( src, src->last ); 113 116 } 114 117
Note: See TracChangeset
for help on using the changeset viewer.