source: src/libcfa/concurrency/threads @ 7fbe450

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since 7fbe450 was 7fbe450, checked in by Thierry Delisle <tdelisle@…>, 8 years ago

No longer using co_main for coroutines/threads, now simply using main

  • Property mode set to 100644
File size: 1.8 KB
Line 
1//                              -*- Mode: CFA -*-
2//
3// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
4//
5// The contents of this file are covered under the licence agreement in the
6// file "LICENCE" distributed with Cforall.
7//
8// threads --
9//
10// Author           : Thierry Delisle
11// Created On       : Tue Jan 17 12:27:26 2016
12// Last Modified By : Thierry Delisle
13// Last Modified On : --
14// Update Count     : 0
15//
16
17#ifndef THREADS_H
18#define THREADS_H
19
20#include "assert"
21#include "invoke.h"
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.
29trait is_thread(dtype T /*| sized(T)*/) {
30      void 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
65
66#endif //THREADS_H
67
68// Local Variables: //
69// mode: c //
70// tab-width: 4 //
71// End: //
Note: See TracBrowser for help on using the repository browser.