RemoveOldIdleConnections() private method

Remove expired drivers from the idle pool
Closing driver is a potentially lengthy operation involving network IO. Therefore we do not close expired drivers while holding idlePool.SyncRoot lock. We just remove the old drivers from the idle queue and return them to the caller. The caller will need to close them (or let GC close them)
private RemoveOldIdleConnections ( ) : List
return List
Esempio n. 1
0
        public static void CleanIdleConnections(object obj)
        {
            List <Driver> list = new List <Driver>();

            lock (MySqlPoolManager.pools)
            {
                foreach (string current in MySqlPoolManager.pools.Keys)
                {
                    MySqlPool mySqlPool = MySqlPoolManager.pools[current];
                    list.AddRange(mySqlPool.RemoveOldIdleConnections());
                }
            }
            foreach (Driver current2 in list)
            {
                current2.Close();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Remove drivers that have been idle for too long.
        /// </summary>
        public static void CleanIdleConnections(object obj)
        {
            List <Driver> oldDrivers = new List <Driver>();

            lock (pools.SyncRoot)
            {
                foreach (string key in pools.Keys)
                {
                    MySqlPool pool = (pools[key] as MySqlPool);
                    oldDrivers.AddRange(pool.RemoveOldIdleConnections());
                }
            }
            foreach (Driver driver in oldDrivers)
            {
                driver.Close();
            }
        }
		public static void CleanIdleConnections(object obj)
		{
			List<Driver> list = new List<Driver>();
			Dictionary<string, MySqlPool> obj2 = MySqlPoolManager.pools;
			lock (obj2)
			{
				foreach (string current in MySqlPoolManager.pools.Keys)
				{
					MySqlPool mySqlPool = MySqlPoolManager.pools[current];
					list.AddRange(mySqlPool.RemoveOldIdleConnections());
				}
			}
			using (List<Driver>.Enumerator enumerator2 = list.GetEnumerator())
			{
				while (enumerator2.MoveNext())
				{
					enumerator2.Current.Close();
				}
			}
		}