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