예제 #1
0
 /// <summary>
 /// Closes the specified connection.
 /// </summary>
 /// <param name="connection">The connection.</param>
 public abstract void Close(RawConnection connection);
예제 #2
0
 /// <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();
 }
예제 #3
0
        /// <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);
            }
        }
예제 #4
0
        /// <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(Builder.ConnectionLifetime!=TimeSpan.Zero)
                if(connection.CreationTime.Add(Builder.ConnectionLifetime) < DateTime.Now)
                    return false;

            if(!connection.IsConnected)
                return false;

            return !connection.IsInvalid;
        }
예제 #5
0
파일: Connection.cs 프로젝트: npenin/uss
        /// <summary>
        /// Replaces the invalid connection.
        /// </summary>
        private void ReplaceInvalidConnection()
        {
            if (_connection == null)
                return;

            _connection.MarkAsInvalid();
            _factory.Close(_connection);
            _connection = _factory.Open();
        }
예제 #6
0
파일: Connection.cs 프로젝트: npenin/uss
        /// <summary>
        /// Closes this instance.
        /// </summary>
        public void Close()
        {
            if (_connection == null)
                return;

            _factory.Close(_connection);
            _connection = null;
        }
예제 #7
0
파일: Connection.cs 프로젝트: npenin/uss
 /// <summary>
 /// Opens this instance.
 /// </summary>
 public void Open()
 {
     _connection = _factory.Open();
 }