Last change
on this file since ecaedf35 was
7edf912,
checked in by Peter A. Buhr <pabuhr@…>, 14 months ago
|
formatting, replace constructor calls with set_allocation 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 | static inline void ?{}( p_msg & this ) { this.count = 0; } |
---|
17 | |
---|
18 | ping * pi; |
---|
19 | pong * po; |
---|
20 | size_t times = 100000; |
---|
21 | |
---|
22 | allocation receive( ping & receiver, p_msg & msg ) { |
---|
23 | msg.count++; |
---|
24 | if ( msg.count > times ) return Finished; |
---|
25 | |
---|
26 | allocation retval = Nodelete; |
---|
27 | if ( msg.count == times ) retval = Finished; |
---|
28 | *po | msg; |
---|
29 | return retval; |
---|
30 | } |
---|
31 | |
---|
32 | allocation receive( pong & receiver, p_msg & msg ) { |
---|
33 | msg.count++; |
---|
34 | if ( msg.count > times ) return Finished; |
---|
35 | |
---|
36 | allocation retval = Nodelete; |
---|
37 | if ( msg.count == times ) retval = Finished; |
---|
38 | *pi | msg; |
---|
39 | return retval; |
---|
40 | } |
---|
41 | |
---|
42 | size_t Processors = 2; |
---|
43 | |
---|
44 | int main( int argc, char * argv[] ) { |
---|
45 | sout | "start"; |
---|
46 | |
---|
47 | processor p[Processors - 1]; |
---|
48 | |
---|
49 | start_actor_system( Processors ); // test passing number of processors |
---|
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 | sout | "end"; |
---|
59 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.