ADT
ast-experimental
Last change
on this file since 13f066d was 1f35220, checked in by caparsons <caparson@…>, 3 years ago |
updated test params so that they ran for appropriate duration
|
-
Property mode
set to
100644
|
File size:
1.5 KB
|
Line | |
---|
1 | #include <actor.hfa>
|
---|
2 | #include <fstream.hfa>
|
---|
3 | #include <stdlib.hfa>
|
---|
4 | #include <string.h>
|
---|
5 | #include <stdio.h>
|
---|
6 |
|
---|
7 | int Times = 1000000; // default values
|
---|
8 |
|
---|
9 | struct derived_actor {
|
---|
10 | inline actor;
|
---|
11 | };
|
---|
12 | void ?{}( derived_actor & this ) { ((actor &)this){}; }
|
---|
13 |
|
---|
14 | struct derived_msg {
|
---|
15 | inline message;
|
---|
16 | int cnt;
|
---|
17 | };
|
---|
18 |
|
---|
19 | void ?{}( derived_msg & this, int cnt ) {
|
---|
20 | ((message &) this){ Delete };
|
---|
21 | this.cnt = cnt;
|
---|
22 | }
|
---|
23 | void ?{}( derived_msg & this ) { ((derived_msg &)this){ 0 }; }
|
---|
24 |
|
---|
25 |
|
---|
26 | Allocation receive( derived_actor & receiver, derived_msg & msg ) {
|
---|
27 | if ( msg.cnt >= Times ) {
|
---|
28 | sout | "Done";
|
---|
29 | return Delete;
|
---|
30 | }
|
---|
31 | derived_msg * d_msg = alloc();
|
---|
32 | (*d_msg){ msg.cnt + 1 };
|
---|
33 | derived_actor * d_actor = alloc();
|
---|
34 | (*d_actor){};
|
---|
35 | *d_actor | *d_msg;
|
---|
36 | return Delete;
|
---|
37 | }
|
---|
38 |
|
---|
39 | int main( int argc, char * argv[] ) {
|
---|
40 | switch ( argc ) {
|
---|
41 | case 2:
|
---|
42 | if ( strcmp( argv[1], "d" ) != 0 ) { // default ?
|
---|
43 | Times = atoi( argv[1] );
|
---|
44 | if ( Times < 1 ) goto Usage;
|
---|
45 | } // if
|
---|
46 | case 1: // use defaults
|
---|
47 | break;
|
---|
48 | default:
|
---|
49 | Usage:
|
---|
50 | sout | "Usage: " | argv[0] | " [ times (> 0) ]";
|
---|
51 | exit( EXIT_FAILURE );
|
---|
52 | } // switch
|
---|
53 |
|
---|
54 | printf("starting\n");
|
---|
55 |
|
---|
56 | executor e{ 0, 1, 1, false };
|
---|
57 | start_actor_system( e );
|
---|
58 |
|
---|
59 | printf("started\n");
|
---|
60 |
|
---|
61 | derived_msg * d_msg = alloc();
|
---|
62 | (*d_msg){};
|
---|
63 | derived_actor * d_actor = alloc();
|
---|
64 | (*d_actor){};
|
---|
65 | *d_actor | *d_msg;
|
---|
66 |
|
---|
67 | printf("stopping\n");
|
---|
68 |
|
---|
69 | stop_actor_system();
|
---|
70 |
|
---|
71 | printf("stopped\n");
|
---|
72 |
|
---|
73 | return 0;
|
---|
74 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.