source: tests/coroutine/raii.cfa @ e71e94a

ADTast-experimentalenumpthread-emulationqualifiedEnum
Last change on this file since e71e94a was 427854b, checked in by Thierry Delisle <tdelisle@…>, 5 years ago

First draft implementation of generators, still missing error checking, testing and clean-up

  • Property mode set to 100644
File size: 1.0 KB
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2017 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// raii.cfa --
8//
9// Author           : Thierry Delisle
10// Created On       : Mon May 27 13:39:58 2019
11// Last Modified By :
12// Last Modified On :
13// Update Count     :
14//
15
16#include <fstream.hfa>
17#include <coroutine.hfa>
18
19struct Raii {
20        const char * name;
21};
22
23void ?{}( Raii & this, const char * name ) {
24        this.name = name;
25        sout | "Raii Ctor" | this.name;
26}
27
28void ^?{}( Raii & this ) {
29        sout | "Raii Dtor" | this.name;
30}
31
32coroutine Cor {};
33
34void ?{}( Cor & this ) {
35        sout | "Coroutine Ctor";
36}
37
38void main( Cor & this ) {
39        Raii raii = { "Coroutine" };
40        sout | "Before Suspend";
41        suspend;
42        sout | "After Suspend";
43}
44
45void ^?{}( Cor & this ) {
46        sout | "Coroutine Dtor";
47}
48
49int main() {
50        Raii raii = { "Main" };
51        Cor cor;
52        resume(cor);
53}
54
55// Local Variables: //
56// tab-width: 4 //
57// compile-command: "cfa -g -Wall -Wextra raii.cfa" //
58// End: //
Note: See TracBrowser for help on using the repository browser.