Ejemplo n.º 1
0
 internal void Free(ConcurrentQueue <JsonRpcConnection> pool, JsonRpcConnection connection)
 {
     using (_shutdownLock.DisposableRead())
     {
         // There is a race between checking the current pool capacity in the condition and
         // and queueing connections to the pool in the else branch.
         // The amount of pooled connections may thus exceed the capacity at times,
         // or some connections might not end up returned into the pool and reused.
         if (_isDisposed || pool.Count >= _capacityPerService)
         {
             connection.Dispose();
         }
         else
         {
             pool.Enqueue(connection);
         }
     }
 }
Ejemplo n.º 2
0
 public void Return(JsonRpcConnection connection)
 => _owner.Free(_queue, connection);