Ignore:
File:
1 edited

Legend:

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

    r427854b rac2b598  
    4646//-----------------------------------------------------------------------------
    4747// Public coroutine API
     48static inline void suspend(void);
     49
     50forall(dtype T | is_coroutine(T))
     51static inline T & resume(T & cor);
     52
    4853forall(dtype T | is_coroutine(T))
    4954void prime(T & cor);
     
    9196
    9297// 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;
     98static 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;
    101105
    102                 assertf( src->last != 0,
    103                         "Attempt to suspend coroutine \"%.256s\" (%p) that has never been resumed.\n"
    104                         "Possible cause is a suspend executed in a member called by a coroutine user rather than by the coroutine main.",
    105                         src->name, src );
    106                 assertf( src->last->state != Halted,
    107                         "Attempt by coroutine \"%.256s\" (%p) to suspend back to terminated coroutine \"%.256s\" (%p).\n"
    108                         "Possible cause is terminated coroutine's main routine has already returned.",
    109                         src->name, src, src->last->name, src->last );
     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 );
    110114
    111                 $ctx_switch( src, src->last );
    112         }
     115        $ctx_switch( src, src->last );
    113116}
    114117
Note: See TracChangeset for help on using the changeset viewer.