Exemplo n.º 1
0
 internal DataCacheThread()
     : base(3)
 {
     m_Thread = new MyServerThread();
     m_Thread.TickSleepTime    = 10;
     m_Thread.ActionNumPerTick = 4096;
     m_Thread.OnStartEvent    += this.OnStart;
     m_Thread.OnTickEvent     += this.OnTick;
 }
 public void ClearPool(int clearOnSize)
 {
     if (m_IsPassive)
     {
         m_ActionQueue.ClearPool(clearOnSize);
     }
     else
     {
         for (int i = 0; i < m_ThreadNum; ++i)
         {
             MyServerThread thread = m_Threads[i];
             thread.ClearPool(clearOnSize);
         }
     }
 }
 private void InitTaskThreads(int threadNum, bool isPassive, int tickSleepTime, int actionNumPerTick)
 {
     if (isPassive)
     {
         m_ActionQueue = new ServerAsyncActionProcessor();
     }
     m_Threads = new MyServerThread[threadNum];
     for (int i = 0; i < threadNum; ++i)
     {
         MyServerThread thread = null;
         if (isPassive)
         {
             thread = new MyServerThread(tickSleepTime, actionNumPerTick, m_ActionQueue);//线程主动取策略
         }
         else
         {
             thread = new MyServerThread(tickSleepTime, actionNumPerTick);//dispatcher主动推策略
         }
         m_Threads[i] = thread;
         thread.Start();
     }
 }