Пример #1
0
 /// <summary>
 /// Disposes the read only client.
 /// </summary>
 /// <param name="client">The client.</param>
 public void DisposeReadOnlyClient(RedisNativeClient client)
 {
     lock (readClients)
     {
         client.Active = false;
         Monitor.PulseAll(readClients);
     }
 }
Пример #2
0
 /// <summary>
 /// Disposes the write client.
 /// </summary>
 /// <param name="client">The client.</param>
 public void DisposeWriteClient(RedisNativeClient client)
 {
     lock (writeClients)
     {
         client.Active = false;
         Monitor.PulseAll(writeClients);
     }
 }
Пример #3
0
        public void DisposeClient(RedisNativeClient client)
        {
            lock (readClients)
            {
                for (var i = 0; i < readClients.Length; i++)
                {
                    var readClient = readClients[i];
                    if (client != readClient)
                    {
                        continue;
                    }
                    if (client.IsDisposed)
                    {
                        readClients[i] = null;
                    }
                    else
                    {
                        client.Active = false;
                    }

                    Monitor.PulseAll(readClients);
                    return;
                }
            }

            lock (writeClients)
            {
                for (var i = 0; i < writeClients.Length; i++)
                {
                    var writeClient = writeClients[i];
                    if (client != writeClient)
                    {
                        continue;
                    }
                    if (client.IsDisposed)
                    {
                        writeClients[i] = null;
                    }
                    else
                    {
                        client.Active = false;
                    }

                    Monitor.PulseAll(writeClients);
                    return;
                }
            }

            //Client not found in any pool, pulse both pools.
            lock (readClients)
                Monitor.PulseAll(readClients);
            lock (writeClients)
                Monitor.PulseAll(writeClients);
        }