#include #include #include #include #include #include struct dummy_actor { actor a; }; // this won't work since the actor isn't inlined struct derived_actor { inline actor; int counter; }; static inline void ?{}( derived_actor & this ) { ((actor &)this){}; this.counter = 0; } struct d_msg { inline message; int num; }; // this isn't a valid receive routine since int is not a message type allocation receive( derived_actor & receiver, int i ) with( receiver ) { mutex(sout) sout | i; counter++; if ( counter == 2 ) return Finished; return Nodelete; } allocation receive( derived_actor & receiver, d_msg & msg ) { return receive( receiver, msg.num ); } struct derived_actor2 { struct nested { int i; }; // testing nested before inline inline actor; }; allocation receive( derived_actor2 & receiver, d_msg & msg ) { mutex(sout) sout | msg.num; return Finished; } struct derived_actor3 { inline actor; }; struct derived_actor4 { inline derived_actor3; }; struct d_msg2 { inline message; int num; }; allocation receive( derived_actor3 & receiver, d_msg & msg ) { mutex(sout) sout | msg.num; if ( msg.num == -1 ) return Nodelete; return Finished; } allocation receive( derived_actor3 & receiver, d_msg2 & msg ) { mutex(sout) sout | msg.num; return Finished; } size_t Processors = 3; int main( int argc, char * argv[] ) { sout | "start"; processor p[Processors - 1]; sout | "basic test"; start_actor_system( Processors ); // test passing number of processors derived_actor a; d_msg b, c; b.num = 1; c.num = 2; a | b | c; stop_actor_system(); sout | "same message and different actors test"; start_actor_system(); // let system detect # of processors derived_actor2 d_ac2_0, d_ac2_1; d_msg d_ac2_msg; d_ac2_msg.num = 3; d_ac2_0 | d_ac2_msg; d_ac2_1 | d_ac2_msg; stop_actor_system(); { sout | "same message and different actor types test"; executor e{ 0, Processors, Processors == 1 ? 1 : Processors * 4, false }; start_actor_system( e ); // pass an explicit executor derived_actor2 d_ac2_2; derived_actor3 d_ac3_0; d_msg d_ac23_msg; d_ac23_msg.num = 4; d_ac3_0 | d_ac23_msg; d_ac2_2 | d_ac23_msg; stop_actor_system(); } // RAII to clean up executor { sout | "different message types, one actor test"; executor e{ 1, Processors, Processors == 1 ? 1 : Processors * 4, true }; start_actor_system( Processors ); derived_actor3 a3; d_msg b1; d_msg2 c2; b1.num = -1; c2.num = 5; a3 | b1 | c2; stop_actor_system(); } // RAII to clean up executor { sout | "nested inheritance actor test"; executor e{ 1, Processors, Processors == 1 ? 1 : Processors * 4, true }; start_actor_system( Processors ); derived_actor4 a4; d_msg b1; d_msg2 c2; b1.num = -1; c2.num = 5; a4 | b1 | c2; stop_actor_system(); } // RAII to clean up executor sout | "end"; }