source:
tests/concurrency/actors/poison.cfa@
9f7285e
Last change on this file since 9f7285e was 41882628, checked in by , 11 months ago | |
---|---|
|
|
File size: 754 bytes |
Rev | Line | |
---|---|---|
[858350a] | 1 | #include <actor.hfa> |
2 | #include <fstream.hfa> | |
3 | #include <stdlib.hfa> | |
4 | #include <string.h> | |
5 | #include <stdio.h> | |
6 | ||
[1950837] | 7 | struct Server { int val; inline actor; }; |
8 | ||
9 | void ?{}( Server & this ) { this.val = 999; } | |
10 | void ^?{}( Server & this ) { this.val = 777; } | |
[858350a] | 11 | |
12 | int main() { | |
[7edf912] | 13 | sout | "Start"; |
[858350a] | 14 | |
[7edf912] | 15 | sout | "Finished"; |
16 | { | |
[41882628] | 17 | actor_start(); |
[7edf912] | 18 | Server s[10]; |
19 | for ( i; 10 ) { | |
20 | s[i] | finished_msg; | |
21 | } | |
[41882628] | 22 | actor_stop(); |
[7edf912] | 23 | } |
[858350a] | 24 | |
[7edf912] | 25 | sout | "Delete"; |
26 | { | |
[41882628] | 27 | actor_start(); |
[7edf912] | 28 | for ( i; 10 ) { |
29 | Server * s = alloc(); | |
30 | (*s){}; | |
31 | (*s) | delete_msg; | |
32 | } | |
[41882628] | 33 | actor_stop(); |
[7edf912] | 34 | } |
[858350a] | 35 | |
[7edf912] | 36 | sout | "Destroy"; |
37 | { | |
[41882628] | 38 | actor_start(); |
[7edf912] | 39 | Server s[10]; |
40 | for ( i; 10 ) | |
41 | s[i] | destroy_msg; | |
[41882628] | 42 | actor_stop(); |
[7edf912] | 43 | for ( i; 10 ) |
44 | if (s[i].val != 777) | |
45 | sout | "Error: dtor not called correctly."; | |
46 | } | |
[858350a] | 47 | |
[7edf912] | 48 | sout | "Done"; |
49 | } |
Note:
See TracBrowser
for help on using the repository browser.