public static void Return(AsyncReadArgs args) { if (args != null) { AsyncReadArgsPool.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 AsyncReadArgs Get(Client c) { AsyncReadArgs args = null; AsyncReadArgsPool.TryTake(out args); if (args == null) { args = new AsyncReadArgs(); } 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; } }