/// <summary> /// Dispose ucma helper. /// </summary> /// <param name="disposing">True => clean up managed resources</param> protected virtual void Dispose(bool disposing) { if (!m_disposed) { if (disposing) { ManualResetEvent waitHandle = m_allDone; m_allDone = null; if (waitHandle != null) { waitHandle.Close(); } TimerWheel timerWheel = m_timerWheel; if (timerWheel != null) { timerWheel.Dispose(); } lock (typeof(UcmaHelper)) { StaticInstance = null; } } m_cleanupNeeded = false; m_disposed = true; } }
public async Task TenK_WithTimerWheel() { TimerWheel wheel = TimerWheel.CreateTimerWheel(TimerWheelBenchmark.resolution, 20); List <Task> timers = new List <Task>(this.timeouts.Count); for (int i = 0; i < this.timeouts.Count; i++) { SimpleTimerWheel.TimerWheelTimer timer = wheel.CreateTimer(TimeSpan.FromMilliseconds(this.timeouts[i])); timers.Add(timer.StartTimerAsync()); } await Task.WhenAll(timers); wheel.Dispose(); }
/// <summary> /// Method to shutdown and clean up collaboration platform. /// </summary> public void Stop() { lock (m_syncRoot) { if (m_cleanupNeeded) { m_cleanupNeeded = false; Helper.Logger.Info("Stopping ucma platform"); var allDone = m_allDone; if (allDone != null) { allDone.Reset(); } this.Cleanup(); //Wait for all operations to complete. if (allDone != null) { bool succeeded = m_allDone.WaitOne(UcmaHelper.MaxTimeoutInMillis, false /*exitContext*/); if (!succeeded) { Helper.Logger.Info("Shutdown did not complete in expected time."); } allDone.Close(); } TimerWheel timerWheel = m_timerWheel; if (timerWheel != null) { timerWheel.Dispose(); } lock (typeof(UcmaHelper)) { StaticInstance = null; } } } }
public void TearDown() { _wheel.Dispose(); Assert.AreEqual(InitialSegmentCount, _pool.CountSegments()); _ticks = 0; }