Changeset deda7e6 for tests/concurrency/actors/types.cfa
- Timestamp:
- Sep 21, 2023, 10:15:58 PM (2 years ago)
- Branches:
- master, stuck-waitfor-destruct
- Children:
- 62c6cfa
- Parents:
- c1e66d9 (diff), 5a1ae14 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - File:
-
- 1 edited
-
tests/concurrency/actors/types.cfa (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tests/concurrency/actors/types.cfa
rc1e66d9 rdeda7e6 9 9 10 10 struct derived_actor { 11 inline actor;12 int counter;11 inline actor; 12 int counter; 13 13 }; 14 14 static inline void ?{}( derived_actor & this ) { ((actor &)this){}; this.counter = 0; } 15 15 16 16 struct d_msg { 17 inline message;18 int num;17 inline message; 18 int num; 19 19 }; 20 20 21 21 // this isn't a valid receive routine since int is not a message type 22 22 allocation receive( derived_actor & receiver, int i ) with( receiver ) { 23 mutex(sout) sout | i;24 counter++;25 if ( counter == 2 ) return Finished;26 return Nodelete;23 mutex(sout) sout | i; 24 counter++; 25 if ( counter == 2 ) return Finished; 26 return Nodelete; 27 27 } 28 28 29 29 allocation receive( derived_actor & receiver, d_msg & msg ) { 30 return receive( receiver, msg.num );30 return receive( receiver, msg.num ); 31 31 } 32 32 33 33 struct derived_actor2 { 34 struct nested { int i; }; // testing nested before inline35 inline actor;34 struct nested { int i; }; // testing nested before inline 35 inline actor; 36 36 }; 37 37 38 38 allocation receive( derived_actor2 & receiver, d_msg & msg ) { 39 mutex(sout) sout | msg.num;40 return Finished;39 mutex(sout) sout | msg.num; 40 return Finished; 41 41 } 42 42 … … 44 44 struct derived_actor4 { inline derived_actor3; }; 45 45 struct d_msg2 { 46 inline message;47 int num;46 inline message; 47 int num; 48 48 }; 49 49 50 50 allocation receive( derived_actor3 & receiver, d_msg & msg ) { 51 mutex(sout) sout | msg.num;52 if ( msg.num == -1 ) return Nodelete;53 return Finished;51 mutex(sout) sout | msg.num; 52 if ( msg.num == -1 ) return Nodelete; 53 return Finished; 54 54 } 55 55 56 56 allocation receive( derived_actor3 & receiver, d_msg2 & msg ) { 57 mutex(sout) sout | msg.num;58 return Finished;57 mutex(sout) sout | msg.num; 58 return Finished; 59 59 } 60 60 … … 62 62 63 63 int main( int argc, char * argv[] ) { 64 printf("start\n");64 sout | "start"; 65 65 66 processor p[Processors - 1];66 processor p[Processors - 1]; 67 67 68 printf("basic test\n");69 start_actor_system( Processors ); // test passing number of processors70 derived_actor a;71 d_msg b, c;72 b.num = 1;73 c.num = 2;74 a | b | c;75 stop_actor_system();68 sout | "basic test"; 69 start_actor_system( Processors ); // test passing number of processors 70 derived_actor a; 71 d_msg b, c; 72 b.num = 1; 73 c.num = 2; 74 a | b | c; 75 stop_actor_system(); 76 76 77 printf("same message and different actors test\n");78 start_actor_system(); // let system detect # of processors79 derived_actor2 d_ac2_0, d_ac2_1;80 d_msg d_ac2_msg;81 d_ac2_msg.num = 3;82 d_ac2_0 | d_ac2_msg;83 d_ac2_1 | d_ac2_msg;84 stop_actor_system();77 sout | "same message and different actors test"; 78 start_actor_system(); // let system detect # of processors 79 derived_actor2 d_ac2_0, d_ac2_1; 80 d_msg d_ac2_msg; 81 d_ac2_msg.num = 3; 82 d_ac2_0 | d_ac2_msg; 83 d_ac2_1 | d_ac2_msg; 84 stop_actor_system(); 85 85 86 87 {88 printf("same message and different actor types test\n");89 executor e{ 0, Processors, Processors == 1 ? 1 : Processors * 4, false };90 start_actor_system( e ); // pass an explicit executor91 derived_actor2 d_ac2_2;92 derived_actor3 d_ac3_0;93 d_msg d_ac23_msg;94 d_ac23_msg.num = 4;95 d_ac3_0 | d_ac23_msg;96 d_ac2_2 | d_ac23_msg;97 stop_actor_system();98 } // RAII to clean up executor86 87 { 88 sout | "same message and different actor types test"; 89 executor e{ 0, Processors, Processors == 1 ? 1 : Processors * 4, false }; 90 start_actor_system( e ); // pass an explicit executor 91 derived_actor2 d_ac2_2; 92 derived_actor3 d_ac3_0; 93 d_msg d_ac23_msg; 94 d_ac23_msg.num = 4; 95 d_ac3_0 | d_ac23_msg; 96 d_ac2_2 | d_ac23_msg; 97 stop_actor_system(); 98 } // RAII to clean up executor 99 99 100 {101 printf("different message types, one actor test\n");102 executor e{ 1, Processors, Processors == 1 ? 1 : Processors * 4, true };103 start_actor_system( Processors );104 derived_actor3 a3;105 d_msg b1;106 d_msg2 c2;107 b1.num = -1;108 c2.num = 5;109 a3 | b1 | c2;110 stop_actor_system();111 } // RAII to clean up executor100 { 101 sout | "different message types, one actor test"; 102 executor e{ 1, Processors, Processors == 1 ? 1 : Processors * 4, true }; 103 start_actor_system( Processors ); 104 derived_actor3 a3; 105 d_msg b1; 106 d_msg2 c2; 107 b1.num = -1; 108 c2.num = 5; 109 a3 | b1 | c2; 110 stop_actor_system(); 111 } // RAII to clean up executor 112 112 113 {114 printf("nested inheritance actor test\n");115 executor e{ 1, Processors, Processors == 1 ? 1 : Processors * 4, true };116 start_actor_system( Processors );117 derived_actor4 a4;118 d_msg b1;119 d_msg2 c2;120 b1.num = -1;121 c2.num = 5;122 a4 | b1 | c2;123 stop_actor_system();124 } // RAII to clean up executor113 { 114 sout | "nested inheritance actor test"; 115 executor e{ 1, Processors, Processors == 1 ? 1 : Processors * 4, true }; 116 start_actor_system( Processors ); 117 derived_actor4 a4; 118 d_msg b1; 119 d_msg2 c2; 120 b1.num = -1; 121 c2.num = 5; 122 a4 | b1 | c2; 123 stop_actor_system(); 124 } // RAII to clean up executor 125 125 126 printf("end\n"); 127 return 0; 126 sout | "end"; 128 127 }
Note:
See TracChangeset
for help on using the changeset viewer.