Ejemplo n.º 1
0
        public void Realese(PeerHandler handler)
        {
            try {
                if (handler.Connection.Connected)
                {
                    _myPool.Add(handler);
                    return;
                }
                else
                {
                    _connectedIps.Remove(handler.Peer.IpAddress.ToString());
                    _peerPool.Realese(handler.Peer);
                }
            } catch { }

            _peerPool.Dispose(handler.Peer);
        }
Ejemplo n.º 2
0
 private void Dispose(bool disposing)
 {
     if (!_disposed && _pool != null)
     {
         _pool.Dispose();
     }
     if (disposing && !_disposed)
     {
         GC.SuppressFinalize(this);
         _disposed = true;
     }
 }
Ejemplo n.º 3
0
        public void AwaitHandler(ManualResetEventSlim eventReset, PeerHandler handler, IResourcePool <PeerHandler> returnPool, int awaitSeconds, int triesCount = 1)
        {
            Task.Factory.StartNew(() => {
                PeerHandler h = handler;
                for (int i = 0; i < triesCount; i++)
                {
                    if (eventReset.Wait(awaitSeconds * 1000))
                    {
                        returnPool.Realese(h);
                        return;
                    }
                }

                returnPool.Dispose(h);
            });
        }
Ejemplo n.º 4
0
        public void When_Disposed_Called_Sockets_That_Have_Already_Been_Disposed_Are_Ignored()
        {
            var pooledSocket = _pool.Acquire() as CouchbasePooledSocket;

            var socket = GetSocket(pooledSocket);

            socket.Shutdown(SocketShutdown.Both);

            _pool.Release(pooledSocket);
            _pool.Dispose();

            Assert.IsFalse(pooledSocket.IsAlive);
            Assert.IsFalse(pooledSocket.IsConnected);
        }
Ejemplo n.º 5
0
 public void TearDown()
 {
     _pool.Dispose();
 }