source: src/libcfa/concurrency/threads @ 63f78f0

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 63f78f0 was bd98b58, checked in by Thierry Delisle <tdelisle@…>, 7 years ago

Kernel now uses intrusive lists and blocking locks for ready queue management.
Update the plan for concurrency.

  • Property mode set to 100644
File size: 1.9 KB
RevLine 
[78b3f52]1//                              -*- Mode: CFA -*-
[0e76cf4f]2//
[78b3f52]3// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
[0e76cf4f]4//
5// The contents of this file are covered under the licence agreement in the
6// file "LICENCE" distributed with Cforall.
7//
[78b3f52]8// threads --
[0e76cf4f]9//
[78b3f52]10// Author           : Thierry Delisle
[6a3d2e7]11// Created On       : Tue Jan 17 12:27:26 2016
[78b3f52]12// Last Modified By : Thierry Delisle
[6a3d2e7]13// Last Modified On : --
[78b3f52]14// Update Count     : 0
[0e76cf4f]15//
16
[17e5e2b]17#ifndef THREADS_H
18#define THREADS_H
[0e76cf4f]19
[8118303]20#include "assert"
21#include "invoke.h"
[78b3f52]22
[8118303]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)*/) {
[7fbe450]30      void main(T* this);
[8118303]31      thread_h* get_thread(T* this);
32        /*void ?{}(T*);
33        void ^?{}(T*);*/
34};
35
[8f49a54]36#define DECL_THREAD(X) static inline thread_h* get_thread(X* this) { return &this->t; } void main(X* this);
37
[8118303]38forall(otype T | is_thread(T) )
39static inline coroutine* get_coroutine(T* this) {
40        return &get_thread(this)->c;
41}
42
[c84e80a]43static inline coroutine* get_coroutine(thread_h* this) {
44        return &this->c;
45}
46
[bd98b58]47thread_h * this_thread(void);
48
[8118303]49//-----------------------------------------------------------------------------
50// Ctors and dtors
51void ?{}(thread_h* this);
52void ^?{}(thread_h* this);
53
54//-----------------------------------------------------------------------------
55// thread runner
56// Structure that actually start and stop threads
57forall(otype T | is_thread(T) )
58struct thread {
59        T handle;
60};
61
62forall(otype T | is_thread(T) )
63void ?{}( thread(T)* this );
64
65forall(otype T, ttype P | is_thread(T) | { void ?{}(T*, P); } )
66void ?{}( thread(T)* this, P params );
67
68forall(otype T | is_thread(T) )
69void ^?{}( thread(T)* this );
70
[bd98b58]71void yield();
[596f987b]72
[17e5e2b]73#endif //THREADS_H
74
[78b3f52]75// Local Variables: //
76// mode: c //
77// tab-width: 4 //
78// End: //
Note: See TracBrowser for help on using the repository browser.