Beispiel #1
0
 public override void Dispose()
 {
     if (!IsDisposed)
     {
         _pool.ReturnConnectionToPool(InnerClient);
         InnerClient = null;
         _pool       = null;
         IsDisposed  = true;
     }
 }
Beispiel #2
0
        private void GetClientFromPool(KdbPlusConnectionStringBuilder builder)
        {
            // get existing pool
            try
            {
                _locker.AcquireReaderLock(-1);
                if (_pools.TryGetValue(builder, out _pool))
                {
                    InnerClient = _pool.GetConnection();
                    return;
                }
            }
            finally
            {
                _locker.ReleaseReaderLock();
            }

            // create new pool
            try
            {
                _locker.AcquireWriterLock(-1);

                if (!_pools.TryGetValue(builder, out _pool))
                {
                    _pool = Factory.CreatePool(builder);
                    _pools.Add(builder, _pool);
                }
            }
            finally
            {
                _locker.ReleaseWriterLock();
            }


            InnerClient = _pool.GetConnection();
        }
Beispiel #3
0
 public PooledKdbPlusDatabaseClient(KdbPlusDatabaseClientPool pool) : base(GetConnection(pool))
 {
     _pool = pool;
 }
Beispiel #4
0
 private static KdbPlusDatabaseClient GetConnection(KdbPlusDatabaseClientPool pool)
 {
     Guard.ThrowIfNull(pool, "pool");
     return(pool.GetConnection());
 }
 public override KdbPlusDatabaseClient CreatePooledClient(KdbPlusDatabaseClientPool pool)
 {
     return(new PooledKdbPlusDatabaseClient(pool));
 }