source: tests/concurrency/actors/inline.cfa @ 4c0acb0

Last change on this file since 4c0acb0 was 8d6786b, checked in by caparsons <caparson@…>, 17 months ago

added new actor test for plan-9 edge case

  • Property mode set to 100644
File size: 1.4 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    {
39        start_actor_system();                                // sets up executor
40        d_actor da;
41        d_msg * dm = alloc();
42        (*dm){ 42, 2423 };
43        da << *dm;
44        stop_actor_system();                                // waits until actors finish
45    }
46    {
47        start_actor_system();                                // sets up executor
48        d_actor da;
49        d_msg2 dm{ 29079 };
50        set_allocation( dm, Nodelete );
51        msg_wrapper * mw = &dm;
52        message * mg = &dm;
53        virtual_dtor * v = &dm;
54        da << dm;
55        stop_actor_system();                                // waits until actors finish
56    }
57}
Note: See TracBrowser for help on using the repository browser.