ADTast-experimental
Last change
on this file since ab2b352 was
4933f18,
checked in by caparsons <caparson@…>, 20 months ago
|
added test case to types test and refactored to remove redundant ctor calls
|
-
Property mode set to
100644
|
File size:
1.2 KB
|
Line | |
---|
1 | #include <fstream.hfa> |
---|
2 | #include <stdlib.hfa> |
---|
3 | #include <string.h> |
---|
4 | #include <stdio.h> |
---|
5 | #include <mutex_stmt.hfa> |
---|
6 | #include <actor.hfa> |
---|
7 | |
---|
8 | struct ping { inline actor; }; |
---|
9 | struct pong { inline actor; }; |
---|
10 | |
---|
11 | struct p_msg { |
---|
12 | inline message; |
---|
13 | size_t count; |
---|
14 | }; |
---|
15 | static inline void ?{}( p_msg & this ) { ((message &)this){}; this.count = 0; } |
---|
16 | |
---|
17 | ping * pi; |
---|
18 | pong * po; |
---|
19 | size_t times = 100000; |
---|
20 | |
---|
21 | Allocation receive( ping & receiver, p_msg & msg ) { |
---|
22 | msg.count++; |
---|
23 | if ( msg.count > times ) return Finished; |
---|
24 | |
---|
25 | Allocation retval = Nodelete; |
---|
26 | if ( msg.count == times ) retval = Finished; |
---|
27 | *po << msg; |
---|
28 | return retval; |
---|
29 | } |
---|
30 | |
---|
31 | Allocation receive( pong & receiver, p_msg & msg ) { |
---|
32 | msg.count++; |
---|
33 | if ( msg.count > times ) return Finished; |
---|
34 | |
---|
35 | Allocation retval = Nodelete; |
---|
36 | if ( msg.count == times ) retval = Finished; |
---|
37 | *pi << msg; |
---|
38 | return retval; |
---|
39 | } |
---|
40 | |
---|
41 | size_t Processors = 2; |
---|
42 | |
---|
43 | int main( int argc, char * argv[] ) { |
---|
44 | printf("start\n"); |
---|
45 | |
---|
46 | processor p[Processors - 1]; |
---|
47 | |
---|
48 | start_actor_system( Processors ); // test passing number of processors |
---|
49 | |
---|
50 | ping pi_actor; |
---|
51 | pong po_actor; |
---|
52 | po = &po_actor; |
---|
53 | pi = &pi_actor; |
---|
54 | p_msg m; |
---|
55 | pi_actor << m; |
---|
56 | stop_actor_system(); |
---|
57 | |
---|
58 | printf("end\n"); |
---|
59 | return 0; |
---|
60 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.