Changes in src/libcfa/concurrency/threads [c84e80a:e15df4c]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/threads
rc84e80a re15df4c 27 27 // Anything that implements this trait can be resumed. 28 28 // Anything that is resumed is a coroutine. 29 trait is_thread(dtype T /*| sized(T)*/) {29 trait is_thread(dtype T | sized(T)) { 30 30 void main(T* this); 31 thread_h* get_thread(T* this); 32 /*void ?{}(T*); 33 void ^?{}(T*);*/ 31 thread* get_thread(T* this); 34 32 }; 35 33 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 36 forall( dtype T | sized(T) | is_thread(T) ) 37 37 static inline coroutine* get_coroutine(T* this) { 38 38 return &get_thread(this)->c; 39 39 } 40 40 41 static inline coroutine* get_coroutine(thread _h* this) {41 static inline coroutine* get_coroutine(thread* this) { 42 42 return &this->c; 43 43 } 44 44 45 thread * this_thread(void); 46 45 47 //----------------------------------------------------------------------------- 46 48 // Ctors and dtors 47 void ?{}(thread _h* this);48 void ^?{}(thread _h* this);49 void ?{}(thread* this); 50 void ^?{}(thread* this); 49 51 50 52 //----------------------------------------------------------------------------- 51 53 // thread runner 52 54 // Structure that actually start and stop threads 53 forall( otype T| is_thread(T) )54 struct thread {55 forall( dtype T | sized(T) | is_thread(T) ) 56 struct scoped { 55 57 T handle; 56 58 }; 57 59 58 forall( otype T | is_thread(T))59 void ?{}( thread(T)* this );60 forall( dtype T | sized(T) | is_thread(T) | { void ?{}(T*); } ) 61 void ?{}( scoped(T)* this ); 60 62 61 forall( otype T, ttype P| is_thread(T) | { void ?{}(T*, P); } )62 void ?{}( thread(T)* this, P params );63 forall( dtype T, ttype P | sized(T) | is_thread(T) | { void ?{}(T*, P); } ) 64 void ?{}( scoped(T)* this, P params ); 63 65 64 forall( otype T | is_thread(T))65 void ^?{}( thread(T)* this );66 forall( dtype T | sized(T) | is_thread(T) | { void ^?{}(T*); } ) 67 void ^?{}( scoped(T)* this ); 66 68 67 //----------------------------------------------------------------------------- 68 // PRIVATE exposed because of inline 69 void yield(); 69 70 70 71 #endif //THREADS_H
Note:
See TracChangeset
for help on using the changeset viewer.