コード例 #1
0
 static SocketHelpers()
 {
     if (!ObjectPoolMgr.ContainsType <SocketAsyncEventArgs>())
     {
         ObjectPoolMgr.RegisterType(CreateSocketArg);
         ObjectPoolMgr.SetMinimumSize <SocketAsyncEventArgs>(CfgMgr.BasicCfg.MaxNumberOfConnections);
     }
 }
コード例 #2
0
        //static int s_AcquiredArgs;
        //static int s_ReleasedArgs;
        //static int s_OutstandingArgs;

        static SocketHelpers()
        {
            if (!ObjectPoolMgr.ContainsType <SocketAsyncEventArgs>())
            {
                ObjectPoolMgr.RegisterType <SocketAsyncEventArgs>(CreateSocketArg);

                // TODO: have the minimum value set in config or find an appropriate minimum.
                ObjectPoolMgr.SetMinimumSize <SocketAsyncEventArgs>(100);
            }
        }
コード例 #3
0
 public void Initialize(ClientManager.CreateClientHandler createClientHandler)
 {
     if (this.IsInitialized)
     {
         throw new Exception("ClientManager already initialized");
     }
     if (!ObjectPoolMgr.ContainsType <SocketAsyncEventArgs>())
     {
         ObjectPoolMgr.RegisterType <SocketAsyncEventArgs>(() => new SocketAsyncEventArgs());
         ObjectPoolMgr.SetMinimumSize <SocketAsyncEventArgs>(100);
     }
     this.m_createClientDelegate  = createClientHandler;
     this.m_semaphore             = new SemaphoreSlim(ClientManager.MaxConcurrentConnections, ClientManager.MaxConcurrentConnections);
     this.m_acceptArgs.Completed += delegate(object sender, SocketAsyncEventArgs e)
     {
         this.ProcessAccept(e);
     };
     this.IsInitialized = true;
 }
コード例 #4
0
        public void Initialize(CreateClientHandler createClientHandler)
        {
            if (IsInitialized)
            {
                throw new Exception("ClientManager already initialized");
            }

            if (!ObjectPoolMgr.ContainsType <PoolableSocketArgs>())
            {
                ObjectPoolMgr.RegisterType(() => new PoolableSocketArgs());
                ObjectPoolMgr.SetMinimumSize <PoolableSocketArgs>(MaxConcurrentConnections);
            }

            m_createClientDelegate = createClientHandler;

            // init semaphore
            m_semaphore             = new SemaphoreSlim(MaxConcurrentConnections, MaxConcurrentConnections);
            m_acceptArgs.Completed += (sender, e) => ProcessAccept(e);

            IsInitialized = true;
        }