bool AsyncIOManager::WaitResult(u32 handle, AsyncIOResult &result) { std::unique_lock<std::mutex> guard(resultsLock_); ScheduleEvent(IO_EVENT_SYNC); while (HasEvents() && ThreadEnabled() && resultsPending_.find(handle) != resultsPending_.end()) { if (PopResult(handle, result)) { return true; } resultsWait_.wait_for(guard, std::chrono::milliseconds(16)); } return PopResult(handle, result); }
bool AsyncIOManager::WaitResult(u32 handle, AsyncIOResult &result) { lock_guard guard(resultsLock_); ScheduleEvent(IO_EVENT_SYNC); while (HasEvents() && ThreadEnabled() && resultsPending_.find(handle) != resultsPending_.end()) { if (PopResult(handle, result)) { return true; } resultsWait_.wait_for(resultsLock_, 16); } if (PopResult(handle, result)) { return true; } return false; }
wxGISEnumReturnType wxGISTaskManager::Wait(int nId, wxString & sMsg) { //block until timeout, error or succeed. wait for nId message wxDateTime dtNow(wxDateTime::Now()); wxTimeSpan sp = wxDateTime::Now() - dtNow; while(sp.GetSeconds() < NET_WAIT_TIMEOUT) { TSKMNGR_RESULT Res = PopResult(nId); if(Res.nId == nId) { sMsg = Res.sMsg; if(Res.nSate == enumGISNetCmdStErr) { return enumGISReturnFailed; } else { return enumGISReturnOk; } } wxTheApp->Yield(true); sp = wxDateTime::Now() - dtNow; }; return enumGISReturnTimeout; }
void NWNMSClient::Update() { if(HasResults()) { ServerListResult result = PopResult(); if (result.roomId == this->currentRoom) this->serverListCallback(result); //delete result.servers; delete result.api; } }
void LispContinuation::CustomCommand(int opcode, const SReference& param) { switch(opcode) { case take_result_as_form: { SReference r; PopResult(r); PushTodo(just_evaluate, r); break; } case duplicate_last_result: { SReference r; PopResult(r); PushResult(r); PushResult(r); break; } default: // this will just throw an exception IntelibContinuation::CustomCommand(opcode, param); } }