Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/concurrency/thread.c

    r9c31349 r17af7d1  
    3535void start( T* this );
    3636
     37forall( dtype T | is_thread(T) )
     38void stop( T* this );
     39
    3740//-----------------------------------------------------------------------------
    3841// Thread ctors and dtors
     
    4144        (&this->cor){};
    4245        this->cor.name = "Anonymous Coroutine";
    43         this->mon.owner = this;
    44         this->mon.recursion = 1;
     46        (&this->terminated){};
    4547        this->next = NULL;
    4648}
     
    6466forall( dtype T | sized(T) | is_thread(T) )
    6567void ^?{}( scoped(T)* this ) {
     68        stop(&this->handle);
    6669        ^(&this->handle){};
    6770}
     
    8386
    8487        ScheduleThread(thrd_h);
     88}
     89
     90forall( dtype T | is_thread(T) )
     91void stop( T* this ) {
     92        wait( & get_thread(this)->terminated );
    8593}
    8694
     
    108116}
    109117
     118// C Helper to signal the termination of a thread_desc
     119// Used in invoke.c
     120extern "C" {
     121        void __thread_signal_termination( thread_desc * this ) {
     122                this->cor.state = Halted;
     123                LIB_DEBUG_PRINTF("Thread end : %p\n", this);
     124                signal( &this->terminated );   
     125        }
     126}
     127
    110128// Local Variables: //
    111129// mode: c //
Note: See TracChangeset for help on using the changeset viewer.