source: tests/concurrency/actors/inline.cfa @ 5f210c0

Last change on this file since 5f210c0 was 7edf912, checked in by Peter A. Buhr <pabuhr@…>, 14 months ago

formatting, replace constructor calls with set_allocation calls

  • Property mode set to 100644
File size: 1.1 KB
Line 
1#include <actor.hfa>
2#include <fstream.hfa>
3
4struct d_actor {
5        inline actor;
6};
7struct msg_wrapper {
8        int b;
9        inline message;
10};
11void ^?{}( msg_wrapper & this ) { sout | "msg_wrapper dtor"; }
12
13struct d_msg {
14        int m;
15        inline msg_wrapper;
16};
17void ?{}( d_msg & this, int m, int b ) { this.m = m; this.b = b; set_allocation( this, Delete ); }
18void ^?{}( d_msg & this ) { sout | "d_msg dtor"; }
19
20allocation receive( d_actor &, d_msg & msg ) {
21        sout | msg.m;
22        sout | msg.b;
23        return Finished;
24}
25
26struct d_msg2 {
27        int m;
28        inline msg_wrapper;
29};
30void ^?{}( d_msg2 & this ) { sout | "d_msg2 dtor";}
31
32allocation receive( d_actor &, d_msg2 & msg ) {
33        sout | msg.m;
34        return Finished;
35}
36
37int main() {
38        processor p;
39        {
40                start_actor_system();                                                           // sets up executor
41                d_actor da;
42                d_msg * dm = alloc();
43                (*dm){ 42, 2423 };
44                da | *dm;
45                stop_actor_system();                                                            // waits until actors finish
46        }
47        {
48                start_actor_system();                                                           // sets up executor
49                d_actor da;
50                d_msg2 dm{ 29079 };
51                set_allocation( dm, Nodelete );
52                msg_wrapper * mw = &dm;
53                message * mg = &dm;
54                virtual_dtor * v = &dm;
55                da | dm;
56                stop_actor_system();                                                            // waits until actors finish
57        }
58}
Note: See TracBrowser for help on using the repository browser.