Esempio n. 1
0
        private static int GetNextFreeAndLock(string rpcChannelCreationOptions)
        {
            int i = -1;

            lock (obj4Lock)
            {
                int?pos = Enumerable.Range(0, _connection_pool_size - 1)
                          .Where(i => !_blocked[i])
                          .Min(i => _rented[i]);
                if (pos == null)
                {
                    throw new InvalidOperationException("Internal error: rabbit connection pool is locked");
                }
                i           = pos.Value;
                _blocked[i] = true;
                _rented[i]++;
            }

            var channel = _rpcChannels[i];

            if (channel == null ||
                channel.Closed)
            {
                channel         = new RpcChannel(rpcChannelCreationOptions, i);
                _rpcChannels[i] = channel;
            }

            lock (obj4Lock)
                _blocked[i] = false;
            return(i);
        }
Esempio n. 2
0
 public static void Return(RpcChannel channel)
 {
     lock (obj4Lock)
         _rented[channel.PoolPosition]--;
 }
Esempio n. 3
0
 public RpcClient(string parameters)
 {
     //_cahannel = RpcChannelPool.Rent(parameters);
     _cahannel = new RpcChannel(parameters, 0);
 }