|
Last change
on this file since b8b64c34 was 6a6e205, checked in by Michael Brooks <mlbrooks@…>, 10 months ago |
|
Clean some warnings from unused variables and pointer-to-int casts.
|
-
Property mode
set to
100644
|
|
File size:
1.1 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 &, 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 &, 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() {
|
|---|
| 45 | sout | "start";
|
|---|
| 46 |
|
|---|
| 47 | processor p[Processors - 1];
|
|---|
| 48 |
|
|---|
| 49 | actor_start( 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 | actor_stop();
|
|---|
| 57 |
|
|---|
| 58 | sout | "end";
|
|---|
| 59 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.