Last change
on this file since 60f4919 was
c880a7b,
checked in by caparsons <caparson@…>, 18 months ago
|
refactored tests to use new name for allocation enum
|
-
Property mode set to
100644
|
File size:
1.2 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 { inline actor; }; |
---|
10 | struct derived_msg { |
---|
11 | inline message; |
---|
12 | int cnt; |
---|
13 | }; |
---|
14 | |
---|
15 | void ?{}( derived_msg & this, int cnt ) { |
---|
16 | ((message &) this){ Nodelete }; |
---|
17 | this.cnt = cnt; |
---|
18 | } |
---|
19 | void ?{}( derived_msg & this ) { ((derived_msg &)this){ 0 }; } |
---|
20 | |
---|
21 | allocation receive( derived_actor & receiver, derived_msg & msg ) { |
---|
22 | if ( msg.cnt >= Times ) { |
---|
23 | sout | "Done"; |
---|
24 | return Finished; |
---|
25 | } |
---|
26 | msg.cnt++; |
---|
27 | receiver << msg; |
---|
28 | return Nodelete; |
---|
29 | } |
---|
30 | |
---|
31 | int main( int argc, char * argv[] ) { |
---|
32 | switch ( argc ) { |
---|
33 | case 2: |
---|
34 | if ( strcmp( argv[1], "d" ) != 0 ) { // default ? |
---|
35 | Times = atoi( argv[1] ); |
---|
36 | if ( Times < 1 ) goto Usage; |
---|
37 | } // if |
---|
38 | case 1: // use defaults |
---|
39 | break; |
---|
40 | default: |
---|
41 | Usage: |
---|
42 | sout | "Usage: " | argv[0] | " [ times (> 0) ]"; |
---|
43 | exit( EXIT_FAILURE ); |
---|
44 | } // switch |
---|
45 | |
---|
46 | printf("starting\n"); |
---|
47 | |
---|
48 | executor e{ 0, 1, 1, false }; |
---|
49 | start_actor_system( e ); |
---|
50 | |
---|
51 | printf("started\n"); |
---|
52 | |
---|
53 | derived_msg msg; |
---|
54 | |
---|
55 | derived_actor actor; |
---|
56 | |
---|
57 | actor << msg; |
---|
58 | |
---|
59 | printf("stopping\n"); |
---|
60 | |
---|
61 | stop_actor_system(); |
---|
62 | |
---|
63 | printf("stopped\n"); |
---|
64 | |
---|
65 | return 0; |
---|
66 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.