Changeset 8118303 for src/libcfa/concurrency/threads
- Timestamp:
- Jan 17, 2017, 5:13:47 PM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- c49bf54
- Parents:
- 7350ff97
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/threads
r7350ff97 r8118303 18 18 #define THREADS_H 19 19 20 #include "assert" 21 #include "invoke.h" 20 22 23 #include "coroutines" 24 25 //----------------------------------------------------------------------------- 26 // Coroutine trait 27 // Anything that implements this trait can be resumed. 28 // Anything that is resumed is a coroutine. 29 trait is_thread(dtype T /*| sized(T)*/) { 30 void co_main(T* this); 31 thread_h* get_thread(T* this); 32 /*void ?{}(T*); 33 void ^?{}(T*);*/ 34 }; 35 36 forall(otype T | is_thread(T) ) 37 static inline coroutine* get_coroutine(T* this) { 38 return &get_thread(this)->c; 39 } 40 41 //----------------------------------------------------------------------------- 42 // Ctors and dtors 43 void ?{}(thread_h* this); 44 void ^?{}(thread_h* this); 45 46 //----------------------------------------------------------------------------- 47 // thread runner 48 // Structure that actually start and stop threads 49 forall(otype T | is_thread(T) ) 50 struct thread { 51 T handle; 52 }; 53 54 forall(otype T | is_thread(T) ) 55 void ?{}( thread(T)* this ); 56 57 forall(otype T, ttype P | is_thread(T) | { void ?{}(T*, P); } ) 58 void ?{}( thread(T)* this, P params ); 59 60 forall(otype T | is_thread(T) ) 61 void ^?{}( thread(T)* this ); 62 63 //----------------------------------------------------------------------------- 64 // PRIVATE exposed because of inline 21 65 22 66 #endif //THREADS_H
Note:
See TracChangeset
for help on using the changeset viewer.