private void UnenrollMultiplexer(int threadId) { MultiplexerData multiplexerData = null; _clientMultiplexerLock.EnterUpgradeableReadLock(); try { // Get from multiplexer by thread ID if (!_clientMultiplexer.TryGetValue(threadId, out multiplexerData)) { throw new Exception("FATAL: multiplexer was missing entry for Thread ID " + threadId); } _clientMultiplexerLock.EnterWriteLock(); try { // Remove entry _clientMultiplexer.Remove(threadId); } finally { _clientMultiplexerLock.ExitWriteLock(); } } finally { _clientMultiplexerLock.ExitUpgradeableReadLock(); } // Now return objects to pools _manualResetEventPool.Push(multiplexerData.ManualResetEvent); }
private MultiplexerData EnrollMultiplexer(int threadId) { MultiplexerData multiplexerData = null; _clientMultiplexerLock.EnterReadLock(); try { if (_clientMultiplexer.TryGetValue(threadId, out multiplexerData)) { return(multiplexerData); } } finally { _clientMultiplexerLock.ExitReadLock(); } multiplexerData = _multiplexerDataPool.Pop(); _clientMultiplexerLock.EnterWriteLock(); try { _clientMultiplexer.Add(threadId, multiplexerData); } finally { _clientMultiplexerLock.ExitWriteLock(); } return(multiplexerData); }
private MultiplexerData GetMultiplexerData(int threadId) { MultiplexerData multiplexerData = null; _clientMultiplexerLock.EnterReadLock(); try { _clientMultiplexer.TryGetValue(threadId, out multiplexerData); } finally { _clientMultiplexerLock.ExitReadLock(); } return(multiplexerData); }
private void SignalMultiplexer(int threadId) { MultiplexerData multiplexerData = null; _clientMultiplexerLock.EnterReadLock(); try { if (!_clientMultiplexer.TryGetValue(threadId, out multiplexerData)) { // Nothing to do return; } } finally { _clientMultiplexerLock.ExitReadLock(); } multiplexerData.ManualResetEvent.Set(); }
private void SignalMultiplexer(int threadId) { MultiplexerData multiplexerData = null;; _clientMultiplexerLock.EnterReadLock(); try { // Get from multiplexer by thread ID if (!_clientMultiplexer.TryGetValue(threadId, out multiplexerData)) { throw new Exception("FATAL: multiplexer was missing entry for Thread ID " + threadId); } multiplexerData.ManualResetEvent.Set(); } finally { _clientMultiplexerLock.ExitReadLock(); } }
private MultiplexerData GetMultiplexerData(int threadId) { MultiplexerData multiplexerData = null; _clientMultiplexerLock.EnterReadLock(); try { // Get from multiplexer by thread ID if (!_clientMultiplexer.TryGetValue(threadId, out multiplexerData)) { throw new Exception("FATAL: multiplexer was missing entry for Thread ID " + threadId); } return(multiplexerData); } finally { _clientMultiplexerLock.ExitReadLock(); } }
private MultiplexerData EnrollMultiplexer(int threadId) { var multiplexerData = new MultiplexerData { ManualResetEvent = _manualResetEventPool.Pop() }; _clientMultiplexerLock.EnterWriteLock(); try { // Add manual reset event for current thread _clientMultiplexer.Add(threadId, multiplexerData); } catch { throw new Exception("FATAL: multiplexer tried to add duplicate entry for Thread ID " + threadId); } finally { _clientMultiplexerLock.ExitWriteLock(); } return(multiplexerData); }