Exemplo n.º 1
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();
        }
Exemplo n.º 2
0
 private static KdbPlusDatabaseClient GetConnection(KdbPlusDatabaseClientPool pool)
 {
     Guard.ThrowIfNull(pool, "pool");
     return(pool.GetConnection());
 }