Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/concurrency/coroutine

    r83a071f9 r6b0b624  
    1010// Author           : Thierry Delisle
    1111// Created On       : Mon Nov 28 12:27:26 2016
    12 // Last Modified By : Thierry Delisle
    13 // Last Modified On : Mon Nov 28 12:27:26 2016
    14 // Update Count     : 0
     12// Last Modified By : Peter A. Buhr
     13// Last Modified On : Sat Jul 22 09:57:17 2017
     14// Update Count     : 2
    1515//
    1616
    17 #ifndef COROUTINES_H
    18 #define COROUTINES_H
     17#pragma once
    1918
    20 #include "assert"
     19#include <assert.h>
    2120#include "invoke.h"
    2221
     
    2625// Anything that is resumed is a coroutine.
    2726trait is_coroutine(dtype T) {
    28       void main(T & this);
    29       coroutine_desc * get_coroutine(T & this);
     27      void main(T * this);
     28      coroutine_desc * get_coroutine(T * this);
    3029};
    3130
    32 #define DECL_COROUTINE(X) static inline coroutine_desc* get_coroutine(X& this) { return &this.__cor; } void main(X& this)
     31#define DECL_COROUTINE(X) static inline coroutine_desc* get_coroutine(X* this) { return &this->__cor; } void main(X* this)
    3332
    3433//-----------------------------------------------------------------------------
    3534// Ctors and dtors
    36 void ?{}(coStack_t & this);
    37 void ?{}(coroutine_desc & this);
    38 void ?{}(coroutine_desc & this, const char * name);
    39 void ^?{}(coStack_t & this);
    40 void ^?{}(coroutine_desc & this);
     35void ?{}(coStack_t * this);
     36void ?{}(coroutine_desc * this);
     37void ?{}(coroutine_desc * this, const char * name);
     38void ^?{}(coStack_t * this);
     39void ^?{}(coroutine_desc * this);
    4140
    4241//-----------------------------------------------------------------------------
     
    4544
    4645forall(dtype T | is_coroutine(T))
    47 static inline void resume(T & cor);
     46static inline void resume(T * cor);
    4847
    4948forall(dtype T | is_coroutine(T))
    50 void prime(T & cor);
     49void prime(T * cor);
    5150
    5251//-----------------------------------------------------------------------------
     
    6362
    6463// Get current coroutine
    65 extern volatile thread_local coroutine_desc * this_coroutine;
     64extern thread_local coroutine_desc * volatile this_coroutine;
    6665
    6766// Private wrappers for context switch and stack creation
     
    8786// Resume implementation inlined for performance
    8887forall(dtype T | is_coroutine(T))
    89 static inline void resume(T & cor) {
     88static inline void resume(T * cor) {
    9089        coroutine_desc * src = this_coroutine;          // optimization
    9190        coroutine_desc * dst = get_coroutine(cor);
     
    9392        if( unlikely(!dst->stack.base) ) {
    9493                create_stack(&dst->stack, dst->stack.size);
    95                 CtxStart(&cor, CtxInvokeCoroutine);
     94                CtxStart(cor, CtxInvokeCoroutine);
    9695        }
    9796
     
    129128}
    130129
    131 #endif //COROUTINES_H
    132 
    133130// Local Variables: //
    134131// mode: c //
Note: See TracChangeset for help on using the changeset viewer.