Destroy() public method

Releases all resources used by this instance and shuts down the inner T:Socket. This instance will not be usable anymore.
Use the IDisposable.Dispose method if you want to release this instance back into the pool.
public Destroy ( ) : void
return void
コード例 #1
0
            /// <summary>
            /// Releases an item back into the sockIOPool
            /// </summary>
            /// <param name="socket"></param>
            private void ReleaseSocket(PooledSocket socket)
            {
                if (log.IsDebugEnabled)
                {
                    log.Debug("Releasing socket " + socket.InstanceId);
                    log.Debug("Are we alive? " + this.isAlive);
                }

                if (this.isAlive)
                {
                    // is it still working (i.e. the server is still connected)
                    if (socket.IsAlive)
                    {
                        // mark the item as free
                        this.freeItems.Enqueue(socket);

                        // signal the event so if someone is waiting for it can reuse this item
                        this.semaphore.Release();
                    }
                    else
                    {
                        // kill this item
                        socket.Destroy();

                        // mark ourselves as not working for a while
                        this.MarkAsDead();
                    }
                }
                else
                {
                    // one of our previous sockets has died, so probably all of them
                    // are dead. so, kill the socket (this will eventually clear the sockIOPool as well)
                    socket.Destroy();
                }
            }
コード例 #2
0
            /// <summary>
            /// Releases an item back into the pool
            /// </summary>
            /// <param name="socket"></param>
            private void ReleaseSocket(PooledSocket socket)
            {
                if (log.IsDebugEnabled)
                {
                    log.Debug("Releasing socket " + socket.InstanceId);
                    log.Debug("Are we alive? " + this.isAlive);
                }

                if (this.isAlive)
                {
                    // is it still working (i.e. the server is still connected)
                    if (socket.IsAlive)
                    {
                        // mark the item as free
                        this.freeItems.Push(socket);
                    }
                    else
                    {
                        // kill this item
                        socket.Destroy();

                        // mark ourselves as not working for a while
                        this.MarkAsDead();
                    }
                }
                else
                {
                    // one of our previous sockets has died, so probably all of them
                    // are dead. so, kill the socket (this will eventually clear the pool as well)
                    socket.Destroy();
                }

                // In any event, we want to let any waiters know that we can create a new
                // socket:
                if (semaphore != null)
                {
                    try
                    {
                        semaphore.Release();
                    }
                    catch (ObjectDisposedException)
                    {
                    }
                }
            }
コード例 #3
0
            /// <summary>
            /// Releases an item back into the pool
            /// </summary>
            /// <param name="socket"></param>
            private void ReleaseSocket(PooledSocket socket)
            {
                if (Log.IsDebugEnabled)
                {
                    Log.Debug("Releasing socket " + socket.InstanceId);
                    Log.Debug("Are we alive? " + isAlive);
                }

                if (isAlive)
                {
                    // is it still working (i.e. the server is still connected)
                    if (socket.IsAlive)
                    {
                        // mark the item as free
                        freeItems.Enqueue(socket);

                        // there can be a race condition (see the count check in acquire)
                        // not sure what to do about it
                        Interlocked.Decrement(ref workingCount);

                        // signal the event so if someone is waiting for it can reuse this item
                        itemReleasedEvent.Set();
                    }
                    else
                    {
                        // kill this item
                        socket.Destroy();

                        // mark ourselves as not working for a while
                        MarkAsDead();
                    }
                }
                else
                {
                    // one of our previous sockets has died, so probably all of them are dead
                    // kill the socket thus clearing the pool, and after we become alive
                    // we'll fill the pool with working sockets
                    socket.Destroy();
                }
            }
コード例 #4
0
            /// <summary>
            /// Releases an item back into the pool
            /// </summary>
            /// <param name="socket"></param>
            private void ReleaseSocket(PooledSocket socket)
            {
                if (_isDebugEnabled)
                {
                    _logger.LogDebug("Releasing socket " + socket.InstanceId);
                    _logger.LogDebug("Are we alive? " + this.isAlive);
                }

                if (this.isAlive)
                {
                    // is it still working (i.e. the server is still connected)
                    if (socket.IsAlive)
                    {
                        // mark the item as free
                        this.freeItems.Push(socket);

                        // signal the event so if someone is waiting for it can reuse this item
                        this.semaphore.Release();
                    }
                    else
                    {
                        // kill this item
                        socket.Destroy();

                        // mark ourselves as not working for a while
                        this.MarkAsDead();

                        // make sure to signal the Acquire so it can create a new conenction
                        // if the failure policy keeps the pool alive
                        this.semaphore.Release();
                    }
                }
                else
                {
                    // one of our previous sockets has died, so probably all of them
                    // are dead. so, kill the socket (this will eventually clear the pool as well)
                    socket.Destroy();
                }
            }