/// <summary> /// Returns the connection. /// </summary> /// <param name = "connection">The connection.</param> public override void Close(RawConnection connection) { if(connection == null) throw new ArgumentNullException("connection"); if(!IsAlive(connection)) { lock(_syncObject) { _usedConnections.Remove(connection); _invalidConnections.Add(connection); } return; } lock(_syncObject) { _usedConnections.Remove(connection); _freeConnections.Enqueue(connection); Monitor.Pulse(_syncObject); } }
/// <summary> /// Closes the specified connection. /// </summary> /// <param name="connection">The connection.</param> public override void Close(RawConnection connection){ if(connection == null) throw new ArgumentNullException("connection"); connection.Dispose(); }
/// <summary> /// Closes the specified connection. /// </summary> /// <param name="connection">The connection.</param> public abstract void Close(RawConnection connection);
/// <summary> /// Opens this instance. /// </summary> public void Open() { _connection = _factory.Open(); }
/// <summary> /// Determines whether the specified connection is alive. /// </summary> /// <param name="connection">The connection.</param> /// <returns> /// <c>true</c> if the specified connection is alive; otherwise, <c>false</c>. /// </returns> private bool IsAlive(RawConnection connection) { if(connection == null) throw new ArgumentNullException("connection"); if(!connection.IsConnected) return false; if(connection.IsInvalid) return false; if(Builder.ConnectionLifetime != TimeSpan.Zero) if(connection.Lifetime < DateTime.UtcNow) return false; return true; }