ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change
on this file since 70ead46a was
cca568e,
checked in by Peter A. Buhr <pabuhr@…>, 5 years ago
|
change all example waitfor statements from comma separate to colon
|
-
Property mode set to
100644
|
File size:
1.2 KB
|
Rev | Line | |
---|
[97e8d1e] | 1 | // |
---|
| 2 | // Cforall Version 1.0.0 Copyright (C) 2019 University of Waterloo |
---|
| 3 | // |
---|
| 4 | // The contents of this file are covered under the licence agreement in the |
---|
| 5 | // file "LICENCE" distributed with Cforall. |
---|
| 6 | // |
---|
| 7 | // gortn.cfa -- compare waitfor and go channels |
---|
| 8 | // |
---|
| 9 | // Author : Peter A. Buhr |
---|
| 10 | // Created On : Wed Feb 20 08:02:37 2019 |
---|
| 11 | // Last Modified By : Peter A. Buhr |
---|
[cca568e] | 12 | // Last Modified On : Thu Jan 16 22:43:40 2020 |
---|
| 13 | // Update Count : 5 |
---|
[97e8d1e] | 14 | // |
---|
| 15 | |
---|
| 16 | #include <fstream.hfa> |
---|
| 17 | #include <thread.hfa> |
---|
| 18 | |
---|
| 19 | struct Msg { int i, j; }; |
---|
[49dee5e] | 20 | thread GoRtn { int i; float f; Msg m; }; |
---|
| 21 | void ^?{}( GoRtn & mutex ) {} |
---|
| 22 | void mem1( GoRtn & mutex gortn, int i ) { gortn.i = i; } |
---|
| 23 | void mem2( GoRtn & mutex gortn, float f ) { gortn.f = f; } |
---|
| 24 | void mem3( GoRtn & mutex gortn, Msg m ) { gortn.m = m; } |
---|
[97e8d1e] | 25 | |
---|
[49dee5e] | 26 | void main( GoRtn & gortn ) with( gortn ) { |
---|
| 27 | for () { |
---|
[cca568e] | 28 | waitfor( mem1 : gortn ) sout | i; |
---|
| 29 | or waitfor( mem2 : gortn ) sout | f; |
---|
| 30 | or waitfor( mem3 : gortn ) sout | m.i | m.j; |
---|
| 31 | or waitfor( ^?{} : gortn ) break; |
---|
[97e8d1e] | 32 | } |
---|
| 33 | } |
---|
| 34 | int main() { |
---|
[49dee5e] | 35 | GoRtn gortn; // start thread |
---|
[97e8d1e] | 36 | mem1( gortn, 0 ); |
---|
| 37 | mem2( gortn, 2.5 ); |
---|
| 38 | mem3( gortn, (Msg){ 1, 2} ); |
---|
| 39 | } // wait for completion |
---|
| 40 | |
---|
| 41 | // Local Variables: // |
---|
| 42 | // tab-width: 4 // |
---|
| 43 | // End: // |
---|
Note: See
TracBrowser
for help on using the repository browser.