source: tests/concurrent/actors/static.cfa@ 13f066d

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.3 KB
Line 
1#include <actor.hfa>
2#include <fstream.hfa>
3#include <stdlib.hfa>
4#include <string.h>
5#include <stdio.h>
6
7int Times = 1000000; // default values
8
9struct derived_actor {
10 inline actor;
11};
12void ?{}( derived_actor & this ) { ((actor &)this){}; }
13
14struct derived_msg {
15 inline message;
16 int cnt;
17};
18
19void ?{}( derived_msg & this, int cnt ) {
20 ((message &) this){ Nodelete };
21 this.cnt = cnt;
22}
23void ?{}( derived_msg & this ) { ((derived_msg &)this){ 0 }; }
24
25
26Allocation 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
36int 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.