Ejemplo n.º 1
0
        /// <summary>
        /// 开始线程池
        /// </summary>
        internal void StartThreadPool(int maxThreadsAllowed)
        {
            if (m_LockThreadPool.InLock() == false)
            {
                return;
            }

            // 最多的可处理信号的数量
            m_MaxSignalCount = maxThreadsAllowed * 2 + 2;
            m_ThreadPool     = new IOCPThreadPool(IOCPThreadPool.TIMEOUT_INFINITE, (uint)maxThreadsAllowed);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 停止线程池
        /// </summary>
        internal void StopThreadPool()
        {
            if (m_LockThreadPool.InLock() == true)
            {
                m_LockThreadPool.OutLock();
                return;
            }

            IOCPThreadPool tempThreadPool = m_ThreadPool;

            if (tempThreadPool != null)
            {
                tempThreadPool.Dispose();
            }

            m_ThreadPool = null;
            m_LockThreadPool.OutLock();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 游戏世界的通知信号
        /// </summary>
        public void SetWorldSignal()
        {
            if (m_SignalCount > m_MaxSignalCount)
            {
                return;
            }
            else
            {
                Interlocked.Increment(ref m_SignalCount);
            }

            // 打开默认线程池的处理
            IOCPThreadPool tempThreadPool = m_ThreadPool;

            if (tempThreadPool != null)
            {
                tempThreadPool.QueueUserWorkItem(this.SliceWorld);
            }
        }