Ejemplo n.º 1
0
        TContext CreateContext(Socket socket, long socketID)
        {
            TContext context = m_contextPool.Get();

            if (context == null)
            {
                context = new TContext();
            }
            context.Init(socket, socketID);
            return(context);
        }
Ejemplo n.º 2
0
        protected DnsUdpContext CreateContext()
        {
            DnsUdpContext context = m_contextPool.Get();

            if (context == null)
            {
                context = new DnsUdpContext();
            }
            context.Init();

            return(context);
        }
Ejemplo n.º 3
0
        /// <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);
        }