Changeset 6402 for branches/MPI
- Timestamp:
- 06/09/11 15:54:37 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/MPI/HeuristicLab.MPIAlgorithmRunner/3.3/Program.cs
r6401 r6402 35 35 namespace HeuristicLab.MPIAlgorithmRunner { 36 36 class Program { 37 EventWaitHandle waitHandle = new EventWaitHandle(false, EventResetMode.ManualReset);38 39 37 private static void SetJobStatus(string address) { 40 38 Console.WriteLine("Started service... at " + address); … … 124 122 } 125 123 124 private EventWaitHandle waitHandle; 125 126 126 public void StartAlgorithm(MPI.Communicator communicator) { 127 127 IAlgorithm alg = communicator.Receive<MPITransportWrapper<IAlgorithm>>(0, 0).InnerItem; … … 130 130 Console.WriteLine("Starting algorithm..."); 131 131 132 alg.Stopped += new EventHandler(algorithm_Stopped);133 waitHandle.Reset();134 135 132 alg.Prepare(true); 133 waitHandle = new EventWaitHandle(false, EventResetMode.ManualReset); 134 alg.Started += new EventHandler(alg_Started); 136 135 alg.Start(); 137 136 138 Timer t = new Timer(delegate(object state) { 139 if (alg.ExecutionState == ExecutionState.Started) { 140 Console.WriteLine("Pausing alg..."); 141 alg.Pause(); 137 waitHandle.WaitOne(); 142 138 143 while (alg.ExecutionState != ExecutionState.Paused) { 144 Thread.Sleep(100); 145 } 139 alg.Started -= new EventHandler(alg_Started); 146 140 147 communicator.Send<MPITransportWrapper<ResultCollection>>( 148 new MPITransportWrapper<ResultCollection>(alg.Results), 0, 1); 141 while (alg.ExecutionState != ExecutionState.Stopped) { 142 Console.WriteLine("Pausing alg..."); 143 alg.Pause(); 149 144 150 Console.WriteLine("Sending update..."); 145 while (alg.ExecutionState == ExecutionState.Started) { 146 Thread.Sleep(100); 147 } 151 148 152 Console.WriteLine("Resuming alg..."); 149 communicator.Send<MPITransportWrapper<ResultCollection>>( 150 new MPITransportWrapper<ResultCollection>(alg.Results), 0, 1); 151 152 Console.WriteLine("Sending update..."); 153 154 Console.WriteLine("Resuming alg..."); 155 if (alg.ExecutionState == ExecutionState.Paused) 153 156 alg.Start(); 154 } 155 }, null, updateInterval, updateInterval); 156 157 waitHandle.WaitOne(); 157 Thread.Sleep(updateInterval); 158 } 158 159 159 160 communicator.Send<int>(communicator.Rank, 0, 2); … … 162 163 } 163 164 164 void alg orithm_Stopped(object sender, EventArgs e) {165 void alg_Started(object sender, EventArgs e) { 165 166 waitHandle.Set(); 166 167 }
Note: See TracChangeset
for help on using the changeset viewer.