//private static readonly Dictionary<ILosgapModule, int> frameCounts = new Dictionary<ILosgapModule, int>(); //private static readonly Dictionary<ILosgapModule, double> cumulativeTickTimes = new Dictionary<ILosgapModule, double>(); //private static Stopwatch timer = Stopwatch.StartNew(); public void Start() { while (!isDisposed) { #if DEBUG frameTimer.Start(); #endif for (int i = 0; i < modules.Length; ++i) { #if DEBUG frameTimeoutCulprit = modules[i]; #endif long elapsedMs = pipelineTimer.ElapsedMilliseconds; long tickDeltaMs = elapsedMs - lastTickTimes[i]; if (tickDeltaMs > modules[i].TickIntervalMs) { //if (!frameCounts.ContainsKey(modules[i])) { // frameCounts.Add(modules[i], 0); // cumulativeTickTimes.Add(modules[i], 0f); //} //var timeBefore = timer.Elapsed; modules[i].PipelineIterate(ParallelizationProvider, tickDeltaMs); lastTickTimes[i] = elapsedMs; //var iterateTime = (timer.Elapsed - timeBefore).TotalSeconds; //cumulativeTickTimes[modules[i]] += iterateTime; //if (++frameCounts[modules[i]] == 1000) { // Logger.Log("TIMER: " + modules[i].GetType().Name + ": " + (cumulativeTickTimes[modules[i]] / 1000d) + "s avg"); // frameCounts[modules[i]] = 0; // cumulativeTickTimes[modules[i]] = 0; //} } } #if DEBUG frameTimer.Stop(); #endif ParallelizationProvider.MasterHydratePMIQueue(); } ParallelizationProvider.WaitForSlavesToExit(); }
public void TestWaitForSlavesToExit() { LosgapSystem.InvokeOnMaster(() => { // Must invoke on master because the PP has assurances that the master thread is invoking operations const int NUM_ITERATIONS = 300; for (int i = 0; i < NUM_ITERATIONS; ++i) { ParallelizationProvider pp = new ParallelizationProvider(); pp.Execute(10, 1, x => { if (x > 10) { Console.WriteLine("This will never be called."); } }); (pp as IDisposable).Dispose(); pp.WaitForSlavesToExit(); } }); }