public static void Return(AsyncSendArgs args) { if (args != null) { AsyncSendArgsPool.Add(args); } }
public void Close() { lock (m){ if (stateClosed) { return; } stateClosed = true; } try { Sock.Close(); } finally { lock (m) { ByteBuffer buf; while ((buf = Buffers.TryDequeue()) != null) { buf.DeRef(); } AsyncReadArgs.Return(ReadArgs); AsyncSendArgs.Return(SendArgs); } OnClose(); } }
public static AsyncSendArgs Get(Client c) { AsyncSendArgs args = null; AsyncSendArgsPool.TryTake(out args); if (args == null) { args = new AsyncSendArgs(); } args.client = c; return(args); }
public Client(Socket s, bool needsConnect = true) { Sock = s; ReadArgs = AsyncReadArgs.Get(this); SendArgs = AsyncSendArgs.Get(this); if (needsConnect) { ConnectArgs = new AsyncConnectArgs(connect_complete); } else { stateConnected = true; } }