Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        private MultiplexerData GetMultiplexerData(int threadId)
        {
            MultiplexerData multiplexerData = null;

            _clientMultiplexerLock.EnterReadLock();
            try
            {
                _clientMultiplexer.TryGetValue(threadId, out multiplexerData);
            }
            finally
            {
                _clientMultiplexerLock.ExitReadLock();
            }

            return(multiplexerData);
        }
Beispiel #4
0
        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();
        }
Beispiel #5
0
        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();
            }
        }
Beispiel #6
0
        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();
            }
        }
Beispiel #7
0
        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);
        }