コード例 #1
0
 public void Purge()
 {
     ConnectionState[] values = null;
     connectionsLock.ReadUpgradable(delegate
     {
         values = new ConnectionState[connections.Count];
         connections.Values.CopyTo(values, 0);
         connectionsLock.Write(delegate
         {
             connections.Clear();
             ZeroCount();
         });
     });
     foreach (var state in values)
     {
         try
         {
             Close(state);
         }
         catch (Exception ex)
         {
             if (SocketServer.log.IsErrorEnabled)
             {
                 SocketServer.log.ErrorFormat("Exception closing socket during shutdown: {0}", ex.ToString());
             }
         }
     }
 }
コード例 #2
0
 private void AddKeySpaceInfo <T>(DataBuffer keySpace)
 {
     if (!_allowsDrops)
     {
         return;
     }
     _keyspaceInfoLock.ReadUpgradable(() =>
     {
         if (!_keyspaceInfos.ContainsKey(keySpace))
         {
             _keyspaceInfoLock.Write(() =>
             {
                 _keyspaceInfos[keySpace] = KeyspaceInfo.Create <T>();
             });
         }
     });
 }