Changeset 7edf912 for tests/concurrency/actors/executor.cfa
- Timestamp:
- Sep 17, 2023, 10:17:50 PM (10 months ago)
- Branches:
- master
- Children:
- a2c2363
- Parents:
- 50be8af
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/concurrency/actors/executor.cfa
r50be8af r7edf912 10 10 static int ids = 0; 11 11 struct d_actor { 12 13 14 12 inline actor; 13 d_actor * gstart; 14 int id, rounds, recs, sends; 15 15 }; 16 16 void ?{}( d_actor & this ) with(this) { 17 18 19 20 21 17 id = ids++; 18 gstart = (&this + (id / Set * Set - id)); // remember group-start array-element 19 rounds = Set * Rounds; // send at least one message to each group member 20 recs = 0; 21 sends = 0; 22 22 } 23 23 … … 25 25 26 26 allocation receive( d_actor & this, d_msg & msg ) with( this ) { 27 28 29 30 31 32 33 34 35 27 if ( recs == rounds ) return Finished; 28 if ( recs % Batch == 0 ) { 29 for ( i; Batch ) { 30 gstart[sends % Set] | shared_msg; 31 sends += 1; 32 } 33 } 34 recs += 1; 35 return Nodelete; 36 36 } 37 37 38 38 int main( int argc, char * argv[] ) { 39 39 switch ( argc ) { 40 40 case 7: 41 41 if ( strcmp( argv[6], "d" ) != 0 ) { // default ? … … 72 72 default: 73 73 exit | "Usage: " | argv[0] 74 74 | " [ actors (> 0 && > set && actors % set == 0 ) | 'd' (default " | Actors 75 75 | ") ] [ set (> 0) | 'd' (default " | Set 76 76 | ") ] [ rounds (> 0) | 'd' (default " | Rounds … … 81 81 } // switch 82 82 83 83 executor e{ Processors, Processors, Processors == 1 ? 1 : Processors * 512, true }; 84 84 85 85 sout | "starting"; 86 86 87 87 start_actor_system( e ); 88 88 89 89 sout | "started"; 90 90 91 91 d_actor actors[ Actors ]; 92 92 93 93 for ( i; Actors ) { … … 95 95 } // for 96 96 97 97 sout | "stopping"; 98 98 99 99 stop_actor_system(); 100 100 101 sout | "stopped"; 102 103 return 0; 101 sout | "stopped"; 104 102 }
Note: See TracChangeset
for help on using the changeset viewer.