public void Close() { log.Debug("Closing Sender"); mutClosed.WaitOne(); if (!closed) { try { closed = true; queue.Close(); thread.Join(timeout); if (thread.IsAlive) { throw new TransportException("join timed out"); } } catch (ThreadInterruptedException e) { throw new TransportException(e); } catch (IOException e) { throw new TransportException(e); } } mutClosed.ReleaseMutex(); }
public void Close_CheckShuttingDown_True() { string name = Guid.NewGuid().ToString(); using (var producer = new CircularBuffer(name, 2, 1)) using (var consumer = new CircularBuffer(name)) { producer.Close(); Assert.IsTrue(consumer.ShuttingDown); } }
public void Close() { _log.Debug("Running: BlockingEnqueue"); const int size = 10; _buf = new CircularBuffer<Object>(size); // add size element anc check that the size +1 add blocks for (int i = 1; i < size; i++) { _buf.Enqueue(new object()); } // check tha the buffer is now full Thread t = new Thread(Go); t.Start(); Thread.Sleep(1000); // the trhead t should block until the buffer is closed Assert.IsTrue(t.ThreadState == ThreadState.WaitSleepJoin); _buf.Close(); Thread.Sleep(100); // t should now be stopped Assert.IsTrue(t.ThreadState == ThreadState.Stopped); }
public void Close() { _log.Debug("Running: BlockingEnqueue"); const int size = 10; _buf = new CircularBuffer <Object>(size); // add size element anc check that the size +1 add blocks for (int i = 1; i < size; i++) { _buf.Enqueue(new object()); } // check tha the buffer is now full Thread t = new Thread(Go); t.Start(); Thread.Sleep(1000); // the trhead t should block until the buffer is closed Assert.IsTrue(t.ThreadState == ThreadState.WaitSleepJoin); _buf.Close(); Thread.Sleep(100); // t should now be stopped Assert.IsTrue(t.ThreadState == ThreadState.Stopped); }