Пример #1
0
        public void ReleaseConnection(Driver driver)
        {
            lock ((inUsePool as ICollection).SyncRoot)
            {
                if (inUsePool.Contains(driver))
                {
                    inUsePool.Remove(driver);
                }
            }

            if (driver.IsTooOld() || beingCleared)
            {
                driver.Close();
                Debug.Assert(!idlePool.Contains(driver));
            }
            else
            {
                lock ((idlePool as ICollection).SyncRoot)
                {
                    idlePool.Enqueue(driver);
                }
            }

            Interlocked.Increment(ref available);
            autoEvent.Set();
        }
Пример #2
0
 public void ReleaseConnection(Driver driver)
 {
     lock (idlePool.SyncRoot)
         lock (inUsePool.SyncRoot)
         {
             inUsePool.Remove(driver);
             if (driver.Settings.ConnectionLifetime != 0 && driver.IsTooOld())
             {
                 driver.Close();
             }
             else
             {
                 idlePool.Enqueue(driver);
             }
         }
 }
Пример #3
0
        public void ReleaseConnection(Driver driver)
        {
            lock (lockObject)
            {
                if (inUsePool.Contains(driver))
                {
                    inUsePool.Remove(driver);
                }

                if (driver.IsTooOld())
                {
                    driver.Close();
                    Debug.Assert(!idlePool.Contains(driver));
                }
                else
                {
                    idlePool.Enqueue(driver);
                }

                // we now either have a connection available or have room to make
                // one so we release one slot in our semaphore
                poolGate.Release();
            }
        }
Пример #4
0
        public void ReleaseConnection(Driver driver)
        {
            lock (lockObject) {
                inUsePool.Remove(driver);
            }

            if (driver.IsTooOld())
            {
                driver.Close();
            }
            else
            {
                lock (lockObject) {
                    idlePool.Enqueue(driver);
                }
            }

            // we now either have a connection available or have room to make
            // one so we release one slot in our semaphore
            if (Interlocked.Increment(ref counter) <= 0)
            {
                poolGate.Release();
            }
        }