void CRunQueue::RequestRConStartup(CRealConsole* pRCon) { bool bFound = false; CVirtualConsole* pVCon = pRCon->VCon(); // Должен вызываться в главной нити, чтобы соблюсти порядок создания при запуске группы _ASSERTE(isMainThread() == true); MSectionLockSimple cs; cs.Lock(mpcs_QueueLock); // May be exist already in queue? for (INT_PTR i = m_RunQueue.size(); (--i) >= 0;) { if (m_RunQueue[i].pVCon == pVCon) { bFound = true; break; } } // push if (!bFound) { RunQueueItem item = {pVCon}; m_RunQueue.push_back(item); } cs.Unlock(); // Trigger our thread AdvanceQueue(); }
void CRunQueue::RequestRConStartup(CRealConsole* pRCon) { bool bFound = false; CVirtualConsole* pVCon = pRCon->VCon(); // Должен вызываться в главной нити, чтобы соблюсти порядок создания при запуске группы _ASSERTE(gpConEmu->isMainThread() == true); EnterCriticalSection(&mcs_QueueLock); // May be exist already in queue? for (INT_PTR i = m_RunQueue.size(); (--i) >= 0;) { if (m_RunQueue[i].pVCon == pVCon) { bFound = true; break; } } // push if (!bFound) { RunQueueItem item = {pVCon}; m_RunQueue.push_back(item); } // Call "in section" to avoid "KillTimer" from main thread AdvanceQueue(); LeaveCriticalSection(&mcs_QueueLock); }
void SpeechSynthesis::OnEnd(const nsSpeechTask* aTask) { MOZ_ASSERT(mCurrentTask == aTask); if (!mSpeechQueue.IsEmpty()) { mSpeechQueue.RemoveElementAt(0); } mCurrentTask = nullptr; AdvanceQueue(); }
void SpeechSynthesis::Resume() { if (!Paused()) { return; } if (mCurrentTask) { mCurrentTask->Resume(); } else { mHoldQueue = false; AdvanceQueue(); } }
void CRunQueue::ProcessRunQueue(bool bFromPostMessage) { // Previous execution was not finished yet? if (mb_InExecution) { if (!m_RunQueue.empty()) { // Ensure timer is ON gpConEmu->SetRunQueueTimer(true, RUNQUEUE_TIMER_DELAY); } // Skip this timer return; } if (bFromPostMessage) { mb_PostRequested = false; } else if (RUNQUEUE_DELAY_LIMIT > 0) { // This is from WM_TIMER, check delay (if not first call) if (mn_LastExecutionTick != 0) { DWORD nCurDelay = (GetTickCount() - mn_LastExecutionTick); if (nCurDelay < RUNQUEUE_DELAY_LIMIT) { // Timeout was not passed till last execution if (!m_RunQueue.empty()) { // Ensure timer is ON gpConEmu->SetRunQueueTimer(true, RUNQUEUE_TIMER_DELAY); } return; } } } _ASSERTE(gpConEmu->isMainThread() == true); if (CVConGroup::InCreateGroup()) { if (!m_RunQueue.empty()) { // Ensure timer is ON gpConEmu->SetRunQueueTimer(true, RUNQUEUE_TIMER_DELAY); } return; } CVConGuard VCon; EnterCriticalSection(&mcs_QueueLock); // Nothing to run? if (m_RunQueue.empty()) { gpConEmu->SetRunQueueTimer(false, 0); } else { while (!m_RunQueue.empty()) { RunQueueItem item = m_RunQueue[0]; m_RunQueue.erase(0); if (gpConEmu->isValid(item.pVCon)) { VCon = item.pVCon; break; } } } LeaveCriticalSection(&mcs_QueueLock); // Queue is empty now? if (VCon.VCon()) { mb_InExecution = true; bool bOpt = gpConEmu->ExecuteProcessPrepare(); VCon->RCon()->OnStartProcessAllowed(); gpConEmu->ExecuteProcessFinished(bOpt); mb_InExecution = false; // Remember last execution moment mn_LastExecutionTick = GetTickCount(); } else { #ifdef _DEBUG if (!m_RunQueue.empty()) { _ASSERTE(m_RunQueue.empty()); } #endif } // Trigger next RCon execution if (!m_RunQueue.empty()) { AdvanceQueue(); } }