Ignore:
Timestamp:
May 9, 2019, 4:47:28 PM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
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
Message:

Removed suspend_then since I believe it cannot be made correct

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/coroutine.hfa

    rf019069 r63364d8  
    6868
    6969        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");
    7170}
    7271
     
    171170}
    172171
    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 it
    177         // Safety note: this is preemption safe since if
    178         // preemption occurs after this line, the pointer
    179         // will also migrate which means this value will
    180         // stay in syn with the TLS
    181         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 coroutine
    195       assert( src->context.SP );
    196 
    197       CtxStore( &src->context, call );
    198         // when CtxStore returns we are back in the src coroutine
    199 
    200         // set state of new coroutine to active
    201         src->state = Active;
    202 
    203         if( unlikely(src->cancellation != NULL) ) {
    204                 _CtxCoroutine_Unwind(src->cancellation, src);
    205         }
    206 
    207         return;
    208 }
    209 
    210172// Local Variables: //
    211173// mode: c //
Note: See TracChangeset for help on using the changeset viewer.