Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/concurrency/threads

    rc84e80a re15df4c  
    2727// Anything that implements this trait can be resumed.
    2828// Anything that is resumed is a coroutine.
    29 trait is_thread(dtype T /*| sized(T)*/) {
     29trait is_thread(dtype T | sized(T)) {
    3030      void main(T* this);
    31       thread_h* get_thread(T* this);
    32         /*void ?{}(T*);
    33         void ^?{}(T*);*/
     31      thread* get_thread(T* this);
    3432};
    3533
    36 forall(otype T | is_thread(T) )
     34#define DECL_THREAD(X) static inline thread* get_thread(X* this) { return &this->t; } void main(X* this);
     35
     36forall( dtype T | sized(T) | is_thread(T) )
    3737static inline coroutine* get_coroutine(T* this) {
    3838        return &get_thread(this)->c;
    3939}
    4040
    41 static inline coroutine* get_coroutine(thread_h* this) {
     41static inline coroutine* get_coroutine(thread* this) {
    4242        return &this->c;
    4343}
    4444
     45thread * this_thread(void);
     46
    4547//-----------------------------------------------------------------------------
    4648// Ctors and dtors
    47 void ?{}(thread_h* this);
    48 void ^?{}(thread_h* this);
     49void ?{}(thread* this);
     50void ^?{}(thread* this);
    4951
    5052//-----------------------------------------------------------------------------
    5153// thread runner
    5254// Structure that actually start and stop threads
    53 forall(otype T | is_thread(T) )
    54 struct thread {
     55forall( dtype T | sized(T) | is_thread(T) )
     56struct scoped {
    5557        T handle;
    5658};
    5759
    58 forall(otype T | is_thread(T) )
    59 void ?{}( thread(T)* this );
     60forall( dtype T | sized(T) | is_thread(T) | { void ?{}(T*); } )
     61void ?{}( scoped(T)* this );
    6062
    61 forall(otype T, ttype P | is_thread(T) | { void ?{}(T*, P); } )
    62 void ?{}( thread(T)* this, P params );
     63forall( dtype T, ttype P | sized(T) | is_thread(T) | { void ?{}(T*, P); } )
     64void ?{}( scoped(T)* this, P params );
    6365
    64 forall(otype T | is_thread(T) )
    65 void ^?{}( thread(T)* this );
     66forall( dtype T | sized(T) | is_thread(T) | { void ^?{}(T*); } )
     67void ^?{}( scoped(T)* this );
    6668
    67 //-----------------------------------------------------------------------------
    68 // PRIVATE exposed because of inline
     69void yield();
    6970
    7071#endif //THREADS_H
Note: See TracChangeset for help on using the changeset viewer.