Ignore:
Timestamp:
Jan 17, 2017, 5:13:47 PM (9 years ago)
Author:
Thierry Delisle <tdelisle@…>
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
Message:

First prototype of cfa threads running (1 thread on 1 processor)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/concurrency/threads

    r7350ff97 r8118303  
    1818#define THREADS_H
    1919
     20#include "assert"
     21#include "invoke.h"
    2022
     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.
     29trait 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
     36forall(otype T | is_thread(T) )
     37static inline coroutine* get_coroutine(T* this) {
     38        return &get_thread(this)->c;
     39}
     40
     41//-----------------------------------------------------------------------------
     42// Ctors and dtors
     43void ?{}(thread_h* this);
     44void ^?{}(thread_h* this);
     45
     46//-----------------------------------------------------------------------------
     47// thread runner
     48// Structure that actually start and stop threads
     49forall(otype T | is_thread(T) )
     50struct thread {
     51        T handle;
     52};
     53
     54forall(otype T | is_thread(T) )
     55void ?{}( thread(T)* this );
     56
     57forall(otype T, ttype P | is_thread(T) | { void ?{}(T*, P); } )
     58void ?{}( thread(T)* this, P params );
     59
     60forall(otype T | is_thread(T) )
     61void ^?{}( thread(T)* this );
     62
     63//-----------------------------------------------------------------------------
     64// PRIVATE exposed because of inline
    2165
    2266#endif //THREADS_H
Note: See TracChangeset for help on using the changeset viewer.