/* XXX Handle timer rollover? */ void Scheduler::DequeueAndUpdateTimeout() { LOG_AM_TRACE("Entering function %s", __FUNCTION__); /* Nothing to do? Then return. A new timeout will be scheduled * the next time something is queued */ if (m_queue.empty() && (!m_localOffsetSet || m_localQueue.empty())) { LOG_AM_DEBUG("Not dequeuing any items as queue is now empty"); if (m_wakeScheduled) { CancelTimeout(); m_wakeScheduled = false; } return; } time_t curTime = time(NULL); LOG_AM_DEBUG("Beginning to dequeue items at time %llu", (unsigned long long)curTime); /* If anything on the queue already happened in the past, dequeue it * and mark it as Scheduled(). */ ProcessQueue(m_queue, curTime); /* Only process the local queue if the timezone offset is known. * Otherwise, wait, because it will be known shortly. */ if (m_localOffsetSet) { ProcessQueue(m_localQueue, curTime + m_localOffset); } LOG_AM_DEBUG("Done dequeuing items"); /* Both queues scheduled and dequeued (or unknown if time zone is not * yet known)? */ if (m_queue.empty() && (!m_localOffsetSet || m_localQueue.empty())) { LOG_AM_DEBUG("No unscheduled items remain"); if (m_wakeScheduled) { CancelTimeout(); m_wakeScheduled = false; } return; } time_t nextWakeup = GetNextStartTime(); if (!m_wakeScheduled || (nextWakeup != m_nextWakeup)) { UpdateTimeout(nextWakeup, curTime); m_nextWakeup = nextWakeup; m_wakeScheduled = true; } }
void *SiteWorkRenderTask::onTask(void *pParam) { RenderTaskContext *pContext = (RenderTaskContext *)(pParam); if (pContext == NULL || pContext->Owner == NULL) { LOG_ERROR("MGD, No render context."); return 0; } SiteWorkRenderTask *pRenderTask = pContext->Owner; ACE_Message_Queue<ACE_MT_SYNCH> *pQueue = pContext->Queue; while (true) { // wait task signal WaitForSingleObject(pContext->hStartTaskEvt, INFINITE); if (pContext->bValid) { ProcessQueue(pQueue); } if (pRenderTask->IsStopped()) break; // notify task completed SetEvent(pContext->hTaskCompEvt); } return 0; }
void KBattleFieldManager::Activate() { if (g_pSO3GameCenter->m_nWorkLoop % (GAME_FPS * 2) == 0) { for (KQUEUE_TABLE::iterator it = m_QueueTable.begin(); it != m_QueueTable.end(); ++it) { ProcessQueue(&it->second); } } if (g_pSO3GameCenter->m_nWorkLoop % (GAME_FPS * 7) == 0) { for (KBATTLE_FIELD_TABLE::iterator it = m_BattleFieldTable.begin(); it != m_BattleFieldTable.end(); ++it) { ProcessBattleFieldCopyTable(it->first, &it->second); ProcessNewBattleField(it->first); } } if (g_pSO3GameCenter->m_nWorkLoop % (GAME_FPS * 3) == 0) { ProcessBlackList(); } }
nsEventStatus InputQueue::ReceiveMouseInput(const RefPtr<AsyncPanZoomController>& aTarget, bool aTargetConfirmed, const MouseInput& aEvent, uint64_t* aOutInputBlockId) { // On a new mouse down we can have a new target so we must force a new block // with a new target. bool newBlock = DragTracker::StartsDrag(aEvent); DragBlockState* block = newBlock ? nullptr : mActiveDragBlock.get(); if (block && block->HasReceivedMouseUp()) { block = nullptr; } if (!block && mDragTracker.InDrag()) { // If there's no current drag block, but we're getting a move with a button // down, we need to start a new drag block because we're obviously already // in the middle of a drag (it probably got interrupted by something else). INPQ_LOG("got a drag event outside a drag block, need to create a block to hold it\n"); newBlock = true; } mDragTracker.Update(aEvent); if (!newBlock && !block) { // This input event is not in a drag block, so we're not doing anything // with it, return eIgnore. return nsEventStatus_eIgnore; } if (!block) { MOZ_ASSERT(newBlock); block = new DragBlockState(aTarget, aTargetConfirmed, aEvent); INPQ_LOG("started new drag block %p id %" PRIu64 " for %sconfirmed target %p\n", block, block->GetBlockId(), aTargetConfirmed ? "" : "un", aTarget.get()); mActiveDragBlock = block; CancelAnimationsForNewBlock(block); MaybeRequestContentResponse(aTarget, block); } if (aOutInputBlockId) { *aOutInputBlockId = block->GetBlockId(); } mQueuedInputs.AppendElement(MakeUnique<QueuedInput>(aEvent, *block)); ProcessQueue(); if (DragTracker::EndsDrag(aEvent)) { block->MarkMouseUpReceived(); } // The event is part of a drag block and could potentially cause // scrolling, so return DoDefault. return nsEventStatus_eConsumeDoDefault; }
void SingleThreadedSchedulerClient::EmptyQueue() { assert(!m_pscheduler->AreThreadsServicingQueue()); bool should_continue = true; while (should_continue) { ProcessQueue(); LOCK(m_cs_callbacks_pending); should_continue = !m_callbacks_pending.empty(); } }
uint32 FChunkCacheWorker::Run() { while (StopTaskCounter.GetValue() == 0) { int32 ProcessedRequests = ProcessQueue(); if (ProcessedRequests == 0) { QueuedRequestsEvent->Wait(500); } } return 0; }
void Storage::QueuedWrite(u8* data, u16 dataLength, u32 blockId, StorageEventListener* callback) { taskitem task; task.data = data; task.dataLength = dataLength; task.storageBlock = blockId; task.callback = callback; task.operation = operation::OPERATION_WRITE; taskQueue->Put((u8*)&task, sizeof(taskitem)); ProcessQueue(); }
nsEventStatus InputQueue::ReceiveScrollWheelInput(const RefPtr<AsyncPanZoomController>& aTarget, bool aTargetConfirmed, const ScrollWheelInput& aEvent, uint64_t* aOutInputBlockId) { WheelBlockState* block = mActiveWheelBlock.get(); // If the block is not accepting new events we'll create a new input block // (and therefore a new wheel transaction). if (block && (!block->ShouldAcceptNewEvent() || block->MaybeTimeout(aEvent))) { block = nullptr; } MOZ_ASSERT(!block || block->InTransaction()); if (!block) { block = new WheelBlockState(aTarget, aTargetConfirmed, aEvent); INPQ_LOG("started new scroll wheel block %p id %" PRIu64 " for target %p\n", block, block->GetBlockId(), aTarget.get()); mActiveWheelBlock = block; CancelAnimationsForNewBlock(block); MaybeRequestContentResponse(aTarget, block); } else { INPQ_LOG("received new event in block %p\n", block); } if (aOutInputBlockId) { *aOutInputBlockId = block->GetBlockId(); } // Note that the |aTarget| the APZCTM sent us may contradict the confirmed // target set on the block. In this case the confirmed target (which may be // null) should take priority. This is equivalent to just always using the // target (confirmed or not) from the block, which is what // ProcessQueue() does. mQueuedInputs.AppendElement(MakeUnique<QueuedInput>(aEvent, *block)); // The WheelBlockState needs to affix a counter to the event before we process // it. Note that the counter is affixed to the copy in the queue rather than // |aEvent|. block->Update(mQueuedInputs.LastElement()->Input()->AsScrollWheelInput()); ProcessQueue(); return nsEventStatus_eConsumeDoDefault; }
void ImposterManager::Draw() { if(!RenderManager::Instance()->GetOptions()->IsOptionEnabled(RenderOptions::IMPOSTERS_ENABLE)) { return; } ProcessQueue(); List<ImposterNode*>::iterator end = imposters.end(); for(List<ImposterNode*>::iterator iter = imposters.begin(); iter != end; ++iter) { (*iter)->GeneralDraw(); } }
// ------------------------------------------------------------------------------------------------------ // --- WARNING: This does not use the IVisitIndividual interface method of distributing the intervention // --- like StandardInterventionDistributionEventCoordinator. // ------------------------------------------------------------------------------------------------------ void CommunityHealthWorkerEventCoordinator::UpdateNodes( float dt ) { int num_to_distribute = int( float(m_MaxDistributedPerDay) * dt ); if( num_to_distribute > m_CurrentStock ) { num_to_distribute = m_CurrentStock; } float current_time = m_Parent->GetSimulationTime().time; int num_distributed = 0; if( m_pInterventionNode != nullptr ) { num_distributed = ProcessQueue( this, current_time, num_to_distribute, m_QueueNode ); } else { num_distributed = ProcessQueue( this, current_time, num_to_distribute, m_QueueIndividual ); } m_CurrentStock -= num_distributed; std::stringstream ss; ss << "UpdateNodes() gave out " << num_distributed << " '" << m_InterventionName.c_str() << "' interventions; " << m_CurrentStock << " remaining in stock\n"; LOG_INFO( ss.str().c_str() ); }
void InputQueue::ContentReceivedInputBlock(uint64_t aInputBlockId, bool aPreventDefault) { APZThreadUtils::AssertOnControllerThread(); INPQ_LOG("got a content response; block=%" PRIu64 "\n", aInputBlockId); bool success = false; CancelableBlockState* block = FindBlockForId(aInputBlockId, nullptr); if (block) { success = block->SetContentResponse(aPreventDefault); block->RecordContentResponseTime(); } if (success) { ProcessQueue(); } }
int main(int argc, char* argv[]) { if (argc != 2) { std::cerr << "Usage: " << argv[0] << " [run_config.json]"; return -1; } Config c; c.LoadFromJson(path(argv[1])); ProcessMergesDump(c); ProcessNewWordsDump(c); ProcessVertices(c); ProcessEdges(c); ProcessQueue(c); ProcessPairsClasses(c); }
nsresult FileService::LockedFileQueue::Enqueue(FileHelper* aFileHelper) { mQueue.AppendElement(aFileHelper); nsresult rv; if (mLockedFile->mRequestMode == LockedFile::PARALLEL) { rv = aFileHelper->AsyncRun(this); } else { rv = ProcessQueue(); } NS_ENSURE_SUCCESS(rv, rv); return NS_OK; }
void InputQueue::SetAllowedTouchBehavior(uint64_t aInputBlockId, const nsTArray<TouchBehaviorFlags>& aBehaviors) { APZThreadUtils::AssertOnControllerThread(); INPQ_LOG("got allowed touch behaviours; block=%" PRIu64 "\n", aInputBlockId); bool success = false; CancelableBlockState* block = FindBlockForId(aInputBlockId, nullptr); if (block && block->AsTouchBlock()) { success = block->AsTouchBlock()->SetAllowedTouchBehaviors(aBehaviors); block->RecordContentResponseTime(); } else if (block) { NS_WARNING("input block is not a touch block"); } if (success) { ProcessQueue(); } }
void SiteWorkRenderTask::Process() { const ImageRenderTaskArgs *pRenderTaskArgs = NULL; for (ImageRenderOpMapCIt cit = m_renderTaskMap.begin(); cit != m_renderTaskMap.end(); cit ++) { pRenderTaskArgs = cit->second; ACE_Message_Block *mb = new ACE_Message_Block(sizeof(pRenderTaskArgs)); if (mb) { memcpy(mb->wr_ptr(), &pRenderTaskArgs, sizeof(pRenderTaskArgs)); _msgQueue.enqueue_tail(mb); } } m_renderTaskMap.clear(); if (_msgQueue.is_empty() == false) { for (int i = 0; i < _ThreadsCount; i ++) { ResetEvent(pTaskContexts[i].hTaskCompEvt); if (pTaskContexts[i].bValid) { SetEvent(pTaskContexts[i].hStartTaskEvt); } } for (int i = 0; i < _ThreadsCount; i ++) { if (pTaskContexts[i].bValid) { WaitForSingleObject(pTaskContexts[i].hTaskCompEvt, INFINITE); } } // retry again, just afraid thread creating failed. ProcessQueue(&_msgQueue); } }
void InputQueue::SetConfirmedTargetApzc(uint64_t aInputBlockId, const RefPtr<AsyncPanZoomController>& aTargetApzc) { APZThreadUtils::AssertOnControllerThread(); INPQ_LOG("got a target apzc; block=%" PRIu64 " guid=%s\n", aInputBlockId, aTargetApzc ? Stringify(aTargetApzc->GetGuid()).c_str() : ""); bool success = false; InputData* firstInput = nullptr; CancelableBlockState* block = FindBlockForId(aInputBlockId, &firstInput); if (block) { success = block->SetConfirmedTargetApzc(aTargetApzc, InputBlockState::TargetConfirmationState::eConfirmed, firstInput); block->RecordContentResponseTime(); } if (success) { ProcessQueue(); } }
void HttpManager::HandleError(HttpResponse& response, const string_t& error) { HttpClient& client = *FindClient(response.uid); switch (client.mode()) { case kHttpServiceAuthenticateUser: case kHttpServiceGetMetadataById: case kHttpServiceGetMetadataByIdV2: case kHttpServiceSearchTitle: case kHttpServiceAddLibraryEntry: case kHttpServiceDeleteLibraryEntry: case kHttpServiceGetLibraryEntries: case kHttpServiceUpdateLibraryEntry: ServiceManager.HandleHttpError(client.response_, error); break; } FreeConnection(client.request_.url.host); ProcessQueue(); }
void FileService::LockedFileQueue::OnFileHelperComplete(FileHelper* aFileHelper) { if (mLockedFile->mRequestMode == LockedFile::PARALLEL) { PRInt32 index = mQueue.IndexOf(aFileHelper); NS_ASSERTION(index != -1, "We don't know anything about this helper!"); mQueue.RemoveElementAt(index); } else { NS_ASSERTION(mCurrentHelper == aFileHelper, "How can this happen?!"); mCurrentHelper = nullptr; nsresult rv = ProcessQueue(); if (NS_FAILED(rv)) { return; } } }
void OutputWindow::OnLoad() { _hScintilla = (HWND)::SendMessageW(_hNpp, NPPM_CREATESCINTILLAHANDLE, 0, (LPARAM)_hWindow); if (!_hScintilla) { throw gcnew NppException("Failed to create scintilla window for output."); } ::SendMessageA(_hScintilla, SCI_USEPOPUP, 0, 0); ::SendMessageA(_hScintilla, SCI_SETREADONLY, 1, 0); ::SendMessageA(_hScintilla, SCI_SETCODEPAGE, SC_CP_UTF8, 0); RECT clientRect; ::GetClientRect(_hWindow, &clientRect); OnResize(clientRect.right - clientRect.left, clientRect.bottom - clientRect.top); ::ShowWindow(_hScintilla, SW_SHOW); InitStyles(); ProcessQueue(); }
void InputQueue::MainThreadTimeout(uint64_t aInputBlockId) { APZThreadUtils::AssertOnControllerThread(); INPQ_LOG("got a main thread timeout; block=%" PRIu64 "\n", aInputBlockId); bool success = false; InputData* firstInput = nullptr; CancelableBlockState* block = FindBlockForId(aInputBlockId, &firstInput); if (block) { // time out the touch-listener response and also confirm the existing // target apzc in the case where the main thread doesn't get back to us // fast enough. success = block->TimeoutContentResponse(); success |= block->SetConfirmedTargetApzc( block->GetTargetApzc(), InputBlockState::TargetConfirmationState::eTimedOut, firstInput); } if (success) { ProcessQueue(); } }
void EQStream::Process(const unsigned char *buffer, const uint32 length) { static unsigned char newbuffer[2048]; uint32 newlength=0; if (EQProtocolPacket::ValidateCRC(buffer,length,Key)) { if (compressed) { newlength=EQProtocolPacket::Decompress(buffer,length,newbuffer,2048); } else { memcpy(newbuffer,buffer,length); newlength=length; if (encoded) EQProtocolPacket::ChatDecode(newbuffer,newlength-2,Key); } if (buffer[1]!=0x01 && buffer[1]!=0x02 && buffer[1]!=0x1d) newlength-=2; EQProtocolPacket *p = MakeProtocolPacket(newbuffer,newlength); ProcessPacket(p); delete p; ProcessQueue(); } else { Log.Out(Logs::Detail, Logs::Netcode, _L "Incoming packet failed checksum" __L); } }
void SocketManager::MainLoop() { // remove evironment values passed by systemd sd_listen_fds(1); // Daemon is ready to work. sd_notify(0, "READY=1"); m_working = true; while (m_working) { fd_set readSet = m_readSet; fd_set writeSet = m_writeSet; timeval localTempTimeout; timeval *ptrTimeout = &localTempTimeout; // I need to extract timeout from priority_queue. // Timeout in priority_queue may be deprecated. // I need to find some actual one. while (!m_timeoutQueue.empty()) { auto &top = m_timeoutQueue.top(); auto &desc = m_socketDescriptionVector[top.sock]; if (top.time == desc.timeout) { // This timeout matches timeout from socket. // It can be used. break; } else { // This socket was used after timeout in priority queue was set up. // We need to update timeout and find some useable one. Timeout tm = { desc.timeout , top.sock}; m_timeoutQueue.pop(); m_timeoutQueue.push(tm); } } if (m_timeoutQueue.empty()) { LogDebug("No usaable timeout found."); ptrTimeout = NULL; // select will wait without timeout } else { time_t currentTime = time(NULL); auto &pqTimeout = m_timeoutQueue.top(); // 0 means that select won't block and socket will be closed ;-) ptrTimeout->tv_sec = currentTime < pqTimeout.time ? pqTimeout.time - currentTime : 0; ptrTimeout->tv_usec = 0; } int ret = select(m_maxDesc+1, &readSet, &writeSet, NULL, ptrTimeout); if (0 == ret) { // timeout Assert(!m_timeoutQueue.empty()); Timeout pqTimeout = m_timeoutQueue.top(); m_timeoutQueue.pop(); auto &desc = m_socketDescriptionVector[pqTimeout.sock]; if (!desc.isTimeout() || !desc.isOpen()) { // Connection was closed. Timeout is useless... desc.setTimeout(false); continue; } if (pqTimeout.time < desc.timeout) { // Is it possible? // This socket was used after timeout. We need to update timeout. pqTimeout.time = desc.timeout; m_timeoutQueue.push(pqTimeout); continue; } // timeout from m_timeoutQueue matches with socket.timeout // and connection is open. Time to close it! // Putting new timeout in queue here is pointless. desc.setTimeout(false); CloseSocket(pqTimeout.sock); // All done. Now we should process next select ;-) continue; } if (-1 == ret) { switch (errno) { case EINTR: LogDebug("EINTR in select"); break; default: int err = errno; LogError("Error in select: " << GetErrnoString(err)); return; } continue; } for (int i = 0; i < m_maxDesc+1 && ret; ++i) { if (FD_ISSET(i, &readSet)) { ReadyForRead(i); --ret; } if (FD_ISSET(i, &writeSet)) { ReadyForWrite(i); --ret; } } ProcessQueue(); } }
nsEventStatus InputQueue::ReceivePanGestureInput(const RefPtr<AsyncPanZoomController>& aTarget, bool aTargetConfirmed, const PanGestureInput& aEvent, uint64_t* aOutInputBlockId) { if (aEvent.mType == PanGestureInput::PANGESTURE_MAYSTART || aEvent.mType == PanGestureInput::PANGESTURE_CANCELLED) { // Ignore these events for now. return nsEventStatus_eConsumeDoDefault; } PanGestureBlockState* block = nullptr; if (aEvent.mType != PanGestureInput::PANGESTURE_START) { block = mActivePanGestureBlock.get(); } PanGestureInput event = aEvent; nsEventStatus result = nsEventStatus_eConsumeDoDefault; if (!block || block->WasInterrupted()) { if (event.mType != PanGestureInput::PANGESTURE_START) { // Only PANGESTURE_START events are allowed to start a new pan gesture // block, but we really want to start a new block here, so we magically // turn this input into a PANGESTURE_START. INPQ_LOG("transmogrifying pan input %d to PANGESTURE_START for new block\n", event.mType); event.mType = PanGestureInput::PANGESTURE_START; } block = new PanGestureBlockState(aTarget, aTargetConfirmed, event); INPQ_LOG("started new pan gesture block %p id %" PRIu64 " for target %p\n", block, block->GetBlockId(), aTarget.get()); if (aTargetConfirmed && event.mRequiresContentResponseIfCannotScrollHorizontallyInStartDirection && !CanScrollTargetHorizontally(event, block)) { // This event may trigger a swipe gesture, depending on what our caller // wants to do it. We need to suspend handling of this block until we get // a content response which will tell us whether to proceed or abort the // block. block->SetNeedsToWaitForContentResponse(true); // Inform our caller that we haven't scrolled in response to the event // and that a swipe can be started from this event if desired. result = nsEventStatus_eIgnore; } mActivePanGestureBlock = block; CancelAnimationsForNewBlock(block); MaybeRequestContentResponse(aTarget, block); } else { INPQ_LOG("received new event in block %p\n", block); } if (aOutInputBlockId) { *aOutInputBlockId = block->GetBlockId(); } // Note that the |aTarget| the APZCTM sent us may contradict the confirmed // target set on the block. In this case the confirmed target (which may be // null) should take priority. This is equivalent to just always using the // target (confirmed or not) from the block, which is what // ProcessQueue() does. mQueuedInputs.AppendElement(MakeUnique<QueuedInput>(event, *block)); ProcessQueue(); return result; }
nsEventStatus InputQueue::ReceiveTouchInput(const RefPtr<AsyncPanZoomController>& aTarget, bool aTargetConfirmed, const MultiTouchInput& aEvent, uint64_t* aOutInputBlockId) { TouchBlockState* block = nullptr; if (aEvent.mType == MultiTouchInput::MULTITOUCH_START) { nsTArray<TouchBehaviorFlags> currentBehaviors; bool haveBehaviors = false; if (!gfxPrefs::TouchActionEnabled()) { haveBehaviors = true; } else if (mActiveTouchBlock) { haveBehaviors = mActiveTouchBlock->GetAllowedTouchBehaviors(currentBehaviors); // If the behaviours aren't set, but the main-thread response timer on // the block is expired we still treat it as though it has behaviors, // because in that case we still want to interrupt the fast-fling and // use the default behaviours. haveBehaviors |= mActiveTouchBlock->IsContentResponseTimerExpired(); } block = StartNewTouchBlock(aTarget, aTargetConfirmed, false); INPQ_LOG("started new touch block %p id %" PRIu64 " for target %p\n", block, block->GetBlockId(), aTarget.get()); // XXX using the chain from |block| here may be wrong in cases where the // target isn't confirmed and the real target turns out to be something // else. For now assume this is rare enough that it's not an issue. if (mQueuedInputs.IsEmpty() && aEvent.mTouches.Length() == 1 && block->GetOverscrollHandoffChain()->HasFastFlungApzc() && haveBehaviors) { // If we're already in a fast fling, and a single finger goes down, then // we want special handling for the touch event, because it shouldn't get // delivered to content. Note that we don't set this flag when going // from a fast fling to a pinch state (i.e. second finger goes down while // the first finger is moving). block->SetDuringFastFling(); block->SetConfirmedTargetApzc(aTarget, InputBlockState::TargetConfirmationState::eConfirmed, nullptr /* the block was just created so it has no events */); if (gfxPrefs::TouchActionEnabled()) { block->SetAllowedTouchBehaviors(currentBehaviors); } INPQ_LOG("block %p tagged as fast-motion\n", block); } CancelAnimationsForNewBlock(block); MaybeRequestContentResponse(aTarget, block); } else { block = mActiveTouchBlock.get(); if (!block) { NS_WARNING("Received a non-start touch event while no touch blocks active!"); return nsEventStatus_eIgnore; } INPQ_LOG("received new event in block %p\n", block); } if (aOutInputBlockId) { *aOutInputBlockId = block->GetBlockId(); } // Note that the |aTarget| the APZCTM sent us may contradict the confirmed // target set on the block. In this case the confirmed target (which may be // null) should take priority. This is equivalent to just always using the // target (confirmed or not) from the block. RefPtr<AsyncPanZoomController> target = block->GetTargetApzc(); nsEventStatus result = nsEventStatus_eIgnore; // XXX calling ArePointerEventsConsumable on |target| may be wrong here if // the target isn't confirmed and the real target turns out to be something // else. For now assume this is rare enough that it's not an issue. if (block->IsDuringFastFling()) { INPQ_LOG("dropping event due to block %p being in fast motion\n", block); result = nsEventStatus_eConsumeNoDefault; } else if (target && target->ArePointerEventsConsumable(block, aEvent.mTouches.Length())) { if (block->UpdateSlopState(aEvent, true)) { INPQ_LOG("dropping event due to block %p being in slop\n", block); result = nsEventStatus_eConsumeNoDefault; } else { result = nsEventStatus_eConsumeDoDefault; } } else if (block->UpdateSlopState(aEvent, false)) { INPQ_LOG("dropping event due to block %p being in mini-slop\n", block); result = nsEventStatus_eConsumeNoDefault; } mQueuedInputs.AppendElement(MakeUnique<QueuedInput>(aEvent, *block)); ProcessQueue(); return result; }
void HttpManager::MakeRequest(HttpRequest& request, HttpClientMode mode) { AddToQueue(request, mode); ProcessQueue(); }
BOOLEAN SendSRB( IN PVOID DeviceExtension, IN PSCSI_REQUEST_BLOCK Srb ) { PADAPTER_EXTENSION adaptExt = (PADAPTER_EXTENSION)DeviceExtension; PSRB_EXTENSION srbExt = (PSRB_EXTENSION)Srb->SrbExtension; PVOID va = NULL; ULONGLONG pa = 0; ULONG QueueNumber = 0; ULONG OldIrql = 0; ULONG MessageId = 0; BOOLEAN kick = FALSE; STOR_LOCK_HANDLE LockHandle = { 0 }; ULONG status = STOR_STATUS_SUCCESS; ENTER_FN(); SET_VA_PA(); RhelDbgPrint(TRACE_LEVEL_INFORMATION, ("Srb %p issued on %d::%d QueueNumber %d\n", Srb, srbExt->procNum.Group, srbExt->procNum.Number, QueueNumber)); if (adaptExt->num_queues > 1) { QueueNumber = adaptExt->cpu_to_vq_map[srbExt->procNum.Number]; MessageId = QueueNumber + 1; if (CHECKFLAG(adaptExt->perfFlags, STOR_PERF_OPTIMIZE_FOR_COMPLETION_DURING_STARTIO)) { ProcessQueue(DeviceExtension, MessageId, FALSE); } // status = StorPortAcquireMSISpinLock(DeviceExtension, MessageId, &OldIrql); if (status != STOR_STATUS_SUCCESS) { RhelDbgPrint(TRACE_LEVEL_ERROR, ("%s StorPortAcquireMSISpinLock returned status 0x%x\n", __FUNCTION__, status)); } } else { QueueNumber = VIRTIO_SCSI_REQUEST_QUEUE_0; StorPortAcquireSpinLock(DeviceExtension, InterruptLock, NULL, &LockHandle); } if (virtqueue_add_buf(adaptExt->vq[QueueNumber], &srbExt->sg[0], srbExt->out, srbExt->in, &srbExt->cmd, va, pa) >= 0){ kick = TRUE; } else { RhelDbgPrint(TRACE_LEVEL_WARNING, ("%s Cant add packet to queue.\n", __FUNCTION__)); //FIXME } if (adaptExt->num_queues > 1) { // status = StorPortReleaseMSISpinLock(DeviceExtension, MessageId, OldIrql); if (status != STOR_STATUS_SUCCESS) { RhelDbgPrint(TRACE_LEVEL_ERROR, ("%s StorPortReleaseMSISpinLock returned status 0x%x\n", __FUNCTION__, status)); } } else { StorPortReleaseSpinLock(DeviceExtension, &LockHandle); } if (kick == TRUE) { virtqueue_kick(adaptExt->vq[QueueNumber]); } return kick; EXIT_FN(); }
void HttpManager::HandleResponse(HttpResponse& response) { HttpClient& client = *FindClient(response.uid); switch (client.mode()) { case kHttpServiceAuthenticateUser: case kHttpServiceGetMetadataById: case kHttpServiceGetMetadataByIdV2: case kHttpServiceSearchTitle: case kHttpServiceAddLibraryEntry: case kHttpServiceDeleteLibraryEntry: case kHttpServiceGetLibraryEntries: case kHttpServiceUpdateLibraryEntry: ServiceManager.HandleHttpResponse(response); break; case kHttpGetLibraryEntryImage: { int anime_id = static_cast<int>(response.parameter); SaveToFile(client.write_buffer_, anime::GetImagePath(anime_id)); if (ImageDatabase.Load(anime_id, true, false)) ui::OnLibraryEntryImageChange(anime_id); break; } case kHttpFeedCheck: case kHttpFeedCheckAuto: { Feed* feed = reinterpret_cast<Feed*>(response.parameter); if (feed) { bool automatic = client.mode() == kHttpFeedCheckAuto; Aggregator.HandleFeedCheck(*feed, client.write_buffer_, automatic); } break; } case kHttpFeedDownload: case kHttpFeedDownloadAll: { if (Aggregator.ValidateFeedDownload(client.request(), response)) { auto feed = reinterpret_cast<Feed*>(response.parameter); if (feed) { bool download_all = client.mode() == kHttpFeedDownloadAll; Aggregator.HandleFeedDownload(*feed, client.write_buffer_, download_all); } } break; } case kHttpTwitterRequest: case kHttpTwitterAuth: case kHttpTwitterPost: ::Twitter.HandleHttpResponse(client.mode(), response); break; case kHttpTaigaUpdateCheck: if (Taiga.Updater.ParseData(response.body)) if (Taiga.Updater.IsDownloadAllowed()) break; ui::OnUpdateFinished(); break; case kHttpTaigaUpdateDownload: SaveToFile(client.write_buffer_, Taiga.Updater.GetDownloadPath()); Taiga.Updater.RunInstaller(); ui::OnUpdateFinished(); break; } FreeConnection(client.request_.url.host); ProcessQueue(); }