source: tests/concurrent/examples/gortn.cfa @ 66f3bae

ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since 66f3bae 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
Line 
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
12// Last Modified On : Thu Jan 16 22:43:40 2020
13// Update Count     : 5
14//
15
16#include <fstream.hfa>
17#include <thread.hfa>
18
19struct Msg { int i, j; };
20thread GoRtn { int i;  float f;  Msg m; };
21void ^?{}( GoRtn & mutex ) {}
22void mem1( GoRtn & mutex gortn, int i ) { gortn.i = i; }
23void mem2( GoRtn & mutex gortn, float f ) { gortn.f = f; }
24void mem3( GoRtn & mutex gortn, Msg m ) { gortn.m = m; }
25
26void main( GoRtn & gortn ) with( gortn ) {
27        for () {
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;
32        }
33}
34int main() {
35        GoRtn gortn;                                                                            // start thread
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.