Ignore:
File:
1 edited

Legend:

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

    r6b0b624 r83a071f9  
     1//                              -*- Mode: CFA -*-
    12//
    23// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
     
    910// Author           : Thierry Delisle
    1011// Created On       : Tue Jan 17 12:27:26 2017
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 21 22:34:46 2017
    13 // Update Count     : 1
     12// Last Modified By : Thierry Delisle
     13// Last Modified On : --
     14// Update Count     : 0
    1415//
    1516
     
    3233// Thread ctors and dtors
    3334
    34 void ?{}(thread_desc* this) {
    35         (&this->cor){};
    36         this->cor.name = "Anonymous Coroutine";
    37         this->mon.owner = this;
    38         this->mon.recursion = 1;
    39         this->next = NULL;
     35void ?{}(thread_desc& this) {
     36        (this.cor){};
     37        this.cor.name = "Anonymous Coroutine";
     38        this.mon.owner = &this;
     39        this.mon.recursion = 1;
     40        this.next = NULL;
    4041
    41         this->current_monitors      = &this->mon;
    42         this->current_monitor_count = 1;
     42        this.current_monitors      = &this.mon;
     43        this.current_monitor_count = 1;
    4344}
    4445
    45 void ^?{}(thread_desc* this) {
    46         ^(&this->cor){};
     46void ^?{}(thread_desc& this) {
     47        ^(this.cor){};
    4748}
    4849
    49 forall( dtype T | sized(T) | is_thread(T) | { void ?{}(T*); } )
    50 void ?{}( scoped(T)* this ) {
    51         (&this->handle){};
    52         __thrd_start(&this->handle);
     50forall( dtype T | sized(T) | is_thread(T) | { void ?{}(T&); } )
     51void ?{}( scoped(T)& this ) {
     52        (this.handle){};
     53        __thrd_start(this.handle);
    5354}
    5455
    55 forall( dtype T, ttype P | sized(T) | is_thread(T) | { void ?{}(T*, P); } )
    56 void ?{}( scoped(T)* this, P params ) {
    57         (&this->handle){ params };
    58         __thrd_start(&this->handle);
     56forall( dtype T, ttype P | sized(T) | is_thread(T) | { void ?{}(T&, P); } )
     57void ?{}( scoped(T)& this, P params ) {
     58        (this.handle){ params };
     59        __thrd_start(this.handle);
    5960}
    6061
    6162forall( dtype T | sized(T) | is_thread(T) )
    62 void ^?{}( scoped(T)* this ) {
    63         ^(&this->handle){};
     63void ^?{}( scoped(T)& this ) {
     64        ^(this.handle){};
    6465}
    6566
     
    6768// Starting and stopping threads
    6869forall( dtype T | is_thread(T) )
    69 void __thrd_start( T* this ) {
     70void __thrd_start( T& this ) {
    7071        coroutine_desc* thrd_c = get_coroutine(this);
    7172        thread_desc*  thrd_h = get_thread   (this);
     
    7778        create_stack(&thrd_c->stack, thrd_c->stack.size);
    7879        this_coroutine = thrd_c;
    79         CtxStart(this, CtxInvokeThread);
     80        CtxStart(&this, CtxInvokeThread);
    8081        assert( thrd_c->last->stack.context );
    8182        CtxSwitch( thrd_c->last->stack.context, thrd_c->stack.context );
     
    8687
    8788void yield( void ) {
    88         BlockInternal( this_thread );
     89        BlockInternal( (thread_desc *)this_thread );
    8990}
    9091
Note: See TracChangeset for help on using the changeset viewer.