/// <summary> /// 移除实体Key /// </summary> /// <param name="indexValue"></param> internal void Remove(string indexValue) { if (_indexHashSet.Contains(indexValue)) { _indexHashSet.Remove(indexValue); } }
private void ClientWorker(Object context) { TTransport client = (TTransport)context; TTransport inputTransport = null; TTransport outputTransport = null; TProtocol inputProtocol = null; TProtocol outputProtocol = null; try { inputTransport = inputTransportFactory.GetTransport(client); outputTransport = outputTransportFactory.GetTransport(client); inputProtocol = inputProtocolFactory.GetProtocol(inputTransport); outputProtocol = outputProtocolFactory.GetProtocol(outputTransport); while (processor.Process(inputProtocol, outputProtocol)) { //keep processing requests until client disconnects } } catch (TTransportException) { } catch (Exception x) { logDelegate("Error: " + x); } if (inputTransport != null) { inputTransport.Close(); } if (outputTransport != null) { outputTransport.Close(); } lock (clientLock) { clientThreads.Remove(Thread.CurrentThread); Monitor.Pulse(clientLock); } return; }
public void THashSet_Equals_Primitive_Test() { const int value = 1; var hashSet = new THashSet <int> { value }; Assert.IsTrue(hashSet.Contains(value)); hashSet.Remove(value); Assert.IsTrue(hashSet.Count == 0); hashSet.Add(value); Assert.IsTrue(hashSet.Contains(value)); hashSet.Clear(); Assert.IsTrue(hashSet.Count == 0); var newArr = new int[1]; hashSet.Add(value); hashSet.CopyTo(newArr, 0); Assert.IsTrue(newArr.Contains(value)); var en = hashSet.GetEnumerator(); en.MoveNext(); Assert.IsTrue((int)en.Current == value); using (var ien = ((IEnumerable <int>)hashSet).GetEnumerator()) { ien.MoveNext(); Assert.IsTrue(ien.Current == value); } }
private void ClientWorker(Object context) { TTransport client = (TTransport)context; TTransport inputTransport = null; TTransport outputTransport = null; TProtocol inputProtocol = null; TProtocol outputProtocol = null; Object connectionContext = null; try { using (inputTransport = inputTransportFactory.GetTransport(client)) { using (outputTransport = outputTransportFactory.GetTransport(client)) { inputProtocol = inputProtocolFactory.GetProtocol(inputTransport); outputProtocol = outputProtocolFactory.GetProtocol(outputTransport); //Recover event handler (if any) and fire createContext server event when a client connects if (serverEventHandler != null) { connectionContext = serverEventHandler.createContext(inputProtocol, outputProtocol); } //Process client requests until client disconnects while (true) { //Fire processContext server event //N.B. This is the pattern implemented in C++ and the event fires provisionally. //That is to say it may be many minutes between the event firing and the client request //actually arriving or the client may hang up without ever makeing a request. if (serverEventHandler != null) { serverEventHandler.processContext(connectionContext, inputTransport); } //Process client request (blocks until transport is readable) if (!processor.Process(inputProtocol, outputProtocol)) { break; } } } } } catch (TTransportException) { //Usually a client disconnect, expected } catch (Exception x) { //Unexpected logDelegate("Error: " + x); } //Fire deleteContext server event after client disconnects if (serverEventHandler != null) { serverEventHandler.deleteContext(connectionContext, inputProtocol, outputProtocol); } lock (clientLock) { clientThreads.Remove(Thread.CurrentThread); Monitor.Pulse(clientLock); } return; }