Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/concurrency/thread

    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 : Sat Jul 22 09:59:40 2017
    13 // Update Count     : 3
     12// Last Modified By : Thierry Delisle
     13// Last Modified On : --
     14// Update Count     : 0
    1415//
    1516
    16 #pragma once
     17#ifndef THREADS_H
     18#define THREADS_H
    1719
    18 #include <assert.h>
     20#include "assert"
    1921#include "invoke.h"
    2022
     
    2729// Anything that is resumed is a coroutine.
    2830trait is_thread(dtype T) {
    29       void ^?{}(T* mutex this);
    30       void main(T* this);
    31       thread_desc* get_thread(T* this);
     31      void ^?{}(T& mutex this);
     32      void main(T& this);
     33      thread_desc* get_thread(T& this);
    3234};
    3335
    34 #define DECL_THREAD(X) thread_desc* get_thread(X* this) { return &this->__thrd; } void main(X* this)
     36#define DECL_THREAD(X) thread_desc* get_thread(X& this) { return &this.__thrd; } void main(X& this)
    3537
    3638forall( dtype T | is_thread(T) )
    37 static inline coroutine_desc* get_coroutine(T* this) {
     39static inline coroutine_desc* get_coroutine(T & this) {
    3840        return &get_thread(this)->cor;
    3941}
    4042
    4143forall( dtype T | is_thread(T) )
    42 static inline monitor_desc* get_monitor(T * this) {
     44static inline monitor_desc* get_monitor(T & this) {
    4345        return &get_thread(this)->mon;
    4446}
     
    5254}
    5355
    54 extern thread_local thread_desc * volatile this_thread;
     56extern volatile thread_local thread_desc * this_thread;
    5557
    5658forall( dtype T | is_thread(T) )
    57 void __thrd_start( T* this );
     59void __thrd_start( T & this );
    5860
    5961//-----------------------------------------------------------------------------
    6062// Ctors and dtors
    61 void ?{}(thread_desc* this);
    62 void ^?{}(thread_desc* this);
     63void ?{}(thread_desc& this);
     64void ^?{}(thread_desc& this);
    6365
    6466//-----------------------------------------------------------------------------
     
    7072};
    7173
    72 forall( dtype T | sized(T) | is_thread(T) | { void ?{}(T*); } )
    73 void ?{}( scoped(T)* this );
     74forall( dtype T | sized(T) | is_thread(T) | { void ?{}(T&); } )
     75void ?{}( scoped(T)& this );
    7476
    75 forall( dtype T, ttype P | sized(T) | is_thread(T) | { void ?{}(T*, P); } )
    76 void ?{}( scoped(T)* this, P params );
     77forall( dtype T, ttype P | sized(T) | is_thread(T) | { void ?{}(T&, P); } )
     78void ?{}( scoped(T)& this, P params );
    7779
    7880forall( dtype T | sized(T) | is_thread(T) )
    79 void ^?{}( scoped(T)* this );
     81void ^?{}( scoped(T)& this );
    8082
    8183void yield();
    8284void yield( unsigned times );
     85
     86#endif //THREADS_H
    8387
    8488// Local Variables: //
Note: See TracChangeset for help on using the changeset viewer.