source: tests/concurrency/actors/inline.cfa @ 2261bcc

Last change on this file since 2261bcc 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
RevLine 
[8d6786b]1#include <actor.hfa>
2#include <fstream.hfa>
3
4struct d_actor {
[7edf912]5        inline actor;
[8d6786b]6};
7struct msg_wrapper {
[7edf912]8        int b;
9        inline message;
[8d6786b]10};
11void ^?{}( msg_wrapper & this ) { sout | "msg_wrapper dtor"; }
12
13struct d_msg {
[7edf912]14        int m;
15        inline msg_wrapper;
[8d6786b]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 ) {
[7edf912]21        sout | msg.m;
22        sout | msg.b;
23        return Finished;
[8d6786b]24}
25
26struct d_msg2 {
[7edf912]27        int m;
28        inline msg_wrapper;
[8d6786b]29};
30void ^?{}( d_msg2 & this ) { sout | "d_msg2 dtor";}
31
32allocation receive( d_actor &, d_msg2 & msg ) {
[7edf912]33        sout | msg.m;
34        return Finished;
[8d6786b]35}
36
37int main() {
[7edf912]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        }
[8d6786b]58}
Note: See TracBrowser for help on using the repository browser.