ADTast-experimental
Last change
on this file since 1e38178 was
1f35220,
checked in by caparsons <caparson@…>, 21 months ago
|
updated test params so that they ran for appropriate duration
|
-
Property mode set to
100644
|
File size:
1.3 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){ Nodelete }; |
---|
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 Finished; |
---|
30 | } |
---|
31 | msg.cnt++; |
---|
32 | receiver | msg; |
---|
33 | return Nodelete; |
---|
34 | } |
---|
35 | |
---|
36 | int main( int argc, char * argv[] ) { |
---|
37 | switch ( argc ) { |
---|
38 | case 2: |
---|
39 | if ( strcmp( argv[1], "d" ) != 0 ) { // default ? |
---|
40 | Times = atoi( argv[1] ); |
---|
41 | if ( Times < 1 ) goto Usage; |
---|
42 | } // if |
---|
43 | case 1: // use defaults |
---|
44 | break; |
---|
45 | default: |
---|
46 | Usage: |
---|
47 | sout | "Usage: " | argv[0] | " [ times (> 0) ]"; |
---|
48 | exit( EXIT_FAILURE ); |
---|
49 | } // switch |
---|
50 | |
---|
51 | printf("starting\n"); |
---|
52 | |
---|
53 | executor e{ 0, 1, 1, false }; |
---|
54 | start_actor_system( e ); |
---|
55 | |
---|
56 | printf("started\n"); |
---|
57 | |
---|
58 | derived_msg msg; |
---|
59 | |
---|
60 | derived_actor actor; |
---|
61 | |
---|
62 | actor | msg; |
---|
63 | |
---|
64 | printf("stopping\n"); |
---|
65 | |
---|
66 | stop_actor_system(); |
---|
67 | |
---|
68 | printf("stopped\n"); |
---|
69 | |
---|
70 | return 0; |
---|
71 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.