Пример #1
0
        private void _WorkerThread()
        {
            if (null == m_refTaskQ)
            {
                return;
            }
            if (null == m_refTaskResultQ)
            {
                return;
            }

            while (m_bRunWorker)
            {
                DBThreadTask task = m_refTaskQ.FetchTask();
                if (null == task)
                {
                    continue;
                }

                task.OnExecute(m_DB);
                m_refTaskResultQ.Push(task);
            }

            m_bIsDestroyedWorker = true;
        }
Пример #2
0
 public void Push(DBThreadTask refTask)
 {
     lock (m_listTaskResult)
     {
         m_listTaskResult.AddLast(refTask);
     }
 }
Пример #3
0
 public void Push(DBThreadTask pTask)
 {
     lock (m_listTask)
     {
         m_listTask.AddLast(pTask);
     }
     SignalPushEvent();
 }
Пример #4
0
        public bool ExecuteAsync(DBThreadTask pTask)
        {
            if ((DB_THREAD_QSIZE_FREE != m_nMaxTaskQSize) &&
                (m_nMaxTaskQSize < m_TaskQ.Size))
            {
                return(false);
            }

            m_nAsyncExecCount++;

            m_TaskQ.Push(pTask);
            return(true);
        }
Пример #5
0
        private DBThreadTask _FetchTaskUnsafe()
        {
            if (0 == m_listTask.Count)
            {
                return(null);
            }

            DBThreadTask refFetchedTask = m_listTask.First.Value;

            m_listTask.RemoveFirst();

            return(refFetchedTask);
        }
Пример #6
0
        public DBThreadTask PopFront()
        {
            DBThreadTask refTask = null;

            lock (m_listTaskResult)
            {
                if (IsEmpty())
                {
                    return(null);
                }
                refTask = m_listTaskResult.First.Value;
                m_listTaskResult.RemoveFirst();
            }
            return(refTask);
        }
Пример #7
0
        public DBThreadTask FetchTask()
        {
            m_eventPushTast.WaitOne(m_nWaitEventTime);

            if (0 == m_listTask.Count)
            {
                return(null);
            }

            lock (m_listTask)
            {
                DBThreadTask pTask = _FetchTaskUnsafe();
                return(pTask);
            }
        }
Пример #8
0
        public void Update()
        {
            DBThreadTask refTask = null;

            while (true)
            {
                if (m_TaskResultQ.IsEmpty())
                {
                    break;
                }

                refTask = m_TaskResultQ.PopFront();
                if (null == refTask)
                {
                    break;
                }
                refTask.OnCompleted();

                m_dwAsyncCompltedCount++;
            }
        }