TContext CreateContext(Socket socket, long socketID) { TContext context = m_contextPool.Get(); if (context == null) { context = new TContext(); } context.Init(socket, socketID); return(context); }
protected DnsUdpContext CreateContext() { DnsUdpContext context = m_contextPool.Get(); if (context == null) { context = new DnsUdpContext(); } context.Init(); return(context); }
/// <summary> /// Checks the async args pool first, else calls the allocator /// </summary> /// <param name="allocator"></param> /// <returns></returns> public SocketAsyncEventArgs CreateAsyncArgs(Func <SocketAsyncEventArgs> allocator) { SocketAsyncEventArgs args = m_asyncArgsPool.Get(); if (args == null) { args = allocator(); } else { args.AcceptSocket = null; } return(args); }