Ejemplo n.º 1
0
        public ClickHouseConnection(int size, string connectionString) : base(connectionString)
        {
            connectionCount = size;
            var c = 0;

            while (c < connectionCount)
            {
                var conn = new ClickHouseConnection(connectionString);
                conn.currentIndex = c;
                conn.Open();

                _conn.Add(conn);
                _states.Add(true);
                c++;
            }
        }
Ejemplo n.º 2
0
        public ClickHouseConnection GetConnection()
        {
            sema.Wait();
            ClickHouseConnection c = null;
            bool s;

            do
            {
                pointer %= connectionCount;
                s        = (bool)_states[pointer];
                if (s)
                {
                    _states[pointer] = false;
                    c = (ClickHouseConnection)_conn[pointer];
                    Interlocked.Increment(ref pointer);
                    break;
                }
                Interlocked.Increment(ref pointer);
            }while (!s);
            return(c);
        }
Ejemplo n.º 3
0
 public ClickHouseConnection SwapConnection(ClickHouseConnection conn)
 {
     conn.Release();
     return(GetConnection());
 }