void Player::SendOptionToServer() { std::cout << "SendOptionToServer called for Player"<<std::endl; while (!mpParser->IsClangOk()) { mpAgent->CheckCommands(mpObserver); mpAgent->Clang(7, 8); mpObserver->SetCommandSend(); WaitFor(200); } std::cout << "SendOptionToServer - ClangOK"<<std::endl; while (!mpParser->IsSyncOk()) { mpAgent->CheckCommands(mpObserver); mpAgent->SynchSee(); mpObserver->SetCommandSend(); WaitFor(200); } std::cout << "SendOptionToServer SyncOK"<<std::endl; mpAgent->CheckCommands(mpObserver); mpAgent->EarOff(false); mpObserver->SetCommandSend(); WaitFor(200); std::cout << "SendOptionToServer returning"<<std::endl; }
/** * 先启动cmdsender和parser线程 * 等待parser连接server (如果失败的话 在shell现实) * 创建agent * 进入主循环 * 向shell现实结束的信息 */ void Client::RunNormal() { mpCommandSender->Start(); //发送命令线程,向server发送信息 Logger::instance().Start(); //log线程 mpParser->Start(); //分析线程,接受server发来的信息 int past_cycle = 0; do { WaitFor(100); // wait for the parser thread to connect the server if (++past_cycle > 20) { std::cout << PlayerParam::instance().teamName() << ": Connect Server Error ..." << std::endl; return; } } while (mpParser->IsConnectServerOk() == false); ConstructAgent(); SendOptionToServer(); MainLoop(); WaitFor(mpObserver->SelfUnum() * 100); if (mpObserver->SelfUnum() == 0) { std::cout << PlayerParam::instance().teamName() << " Coach: Bye ..." << std::endl; } else { std::cout << PlayerParam::instance().teamName() << " " << mpObserver->SelfUnum() << ": Bye ..." << std::endl; } }
void WebHandler::RewardGift(const std::wstring& giftNames) { auto names = SplitString(giftNames, L","); if (names.size() != 2) return; auto tabName = names[0]; auto giftName = names[1]; CComQIPtr<IHTMLElementCollection> spElementCollection; HRESULT hr = htmlDocument_->get_all(&spElementCollection); //取得表单集合 if (FAILED(hr)) return; auto chosenGiftName = GetElement(spElementCollection, L"id", L"chosenGiftName"); if (!chosenGiftName) return; chosenGiftName->click(); WaitFor(50); auto giftTab = GetElement(spElementCollection, L"id", L"giftTab"); if (!giftTab) return; CComPtr<IDispatch> giftTabDispatch; hr = giftTab->get_all(&giftTabDispatch); //取得表单集合 if (FAILED(hr)) return; CComQIPtr<IHTMLElementCollection> giftTabCollection; hr = giftTabDispatch->QueryInterface(IID_IHTMLElementCollection, (VOID**)&giftTabCollection); if (FAILED(hr)) return; auto selectTab = GetElement(giftTabCollection, L"type", tabName); if (!selectTab) return; selectTab->click(); WaitFor(50); CComQIPtr<IHTMLElementCollection> giftItemCollection; hr = htmlDocument_->get_all(&giftItemCollection); //取得表单集合 if (FAILED(hr)) return; auto giftItem = GetElement(giftItemCollection, L"_giftname", giftName); if (!giftItem) return; giftItem->click(); WaitFor(50); auto sendGift = GetElement(giftItemCollection, L"class", L"button", L"赠送"); if (!sendGift) return; sendGift->click(); }
void DoAutoZero(void){ LCD_FullDisp( " Ready for Auto-Zero", "(Keep Pitob Ass. Out", "& Sampling Pump Off)", " Press Enter Key "); //w8 for user to press ENTER key WaitFor(EnterKey); //Enter key pressed, go to AUTOZERO of Pitot_DP, Orifice_DP and Orifice_GAS_DP. //User is expected to remove any input to system, hence read values are offsets LCD_FullDisp( " Doing Auto-Zero ", "(Keep Pitob Ass. Out", "& Sampling Pump Off)", " "); delay_sec(1); OrifPart_DP.Zero= ExtAnalogRead(Ch_Orifice_DP); LCD_Setcursor(4,2); LCD_Print("------"); //Graphic loading Effect ;) delay_sec(1); Pitot_DP.Zero= ExtAnalogRead(Ch_Pitot_DP); LCD_Print("------"); delay_sec(1); OrifGas_DP.Zero= ExtAnalogRead(Ch_Orifice_Gas_DP); LCD_Print("------"); LCD_FullDisp( " ", " Auto-Zero done ", " Press Enter Key ", " "); WaitFor(EnterKey); }
/** * @brief Sends header information to CC3000 * @param None * @retval None */ long SpiWrite(unsigned char *ucBuf, unsigned short usLength) { int NotAborted = 0; switch (State()) { case eSPI_STATE_POWERUP: NotAborted = WaitFor(eSPI_STATE_INITIALIZED); if (!NotAborted) { break; } // fall through - No break at the end of case case eSPI_STATE_INITIALIZED: NotAborted = SetState(eSPI_STATE_FIRST_WRITE, eAssert); usLength = SpiSetUp(ucBuf,usLength); if (NotAborted) { //Delay for at least 50 us Delay_Microsecond(50); //SPI writes first 4 bytes of data NotAborted = SpiIO(eWrite, ucBuf, 4, TRUE); if (NotAborted) { //Delay for at least 50 us Delay_Microsecond(50); //SPI writes next 4 bytes of data NotAborted = SpiIO(eWrite, &ucBuf[4], usLength - 4, TRUE); } } break; default: NotAborted = WaitFor(eSPI_STATE_IDLE); if(NotAborted) { NotAborted = Reserve(eSPI_STATE_WRITE_WAIT_IRQ); WARN("CC3000 SpiWrite acquire bus"); if(NotAborted) { usLength = SpiSetUp(ucBuf, usLength); NotAborted = WaitFor(eSPI_STATE_WRITE_PROCEED); if(NotAborted) { NotAborted = SpiIO(eWrite, ucBuf, usLength, TRUE); } } } break; } return NotAborted ? usLength : -1; }
TEST_F(AutoConfig_SliderTest, ConcurrentModification) { AutoCurrentContext ctxt; auto mgr = ctxt->Inject<SliderManager>(); auto mic = ctxt->Inject<MonotonicIncreaseChecker>(); ctxt->Initiate(); ASSERT_EQ(2U, mgr->all_sliders.size()) << "Slider manager did not find all sliders as expected"; // Set all integer sliders: for (int i = 0; i < 100; i++) { for (auto& slider : mgr->all_sliders) if(sizeof(int) == slider->size) slider->assigner(i); } // Now set boolean sliders, this should cause our class to exit because // the only boolean slider is there to cause the thread to exit for (auto& slider : mgr->all_sliders) if (sizeof(bool) == slider->size) slider->assigner(1); ASSERT_TRUE(mic->WaitFor(std::chrono::seconds{ 5 })) << "Counter class did not exit in time"; ASSERT_TRUE(mic->succeeded) << "Values received out-of-order in the sequence checker"; }
int8_t Esp8266WiFiPhy::GetWiFiMode(bool flashStored){ string ATCommand; testprintf("\r\nEntering %s ...", __PRETTY_FUNCTION__); // header ATCommand = "AT+CWMODE_"; // stored? if (flashStored){ ATCommand += "DEF"; } else { ATCommand += "CUR"; } //tail ATCommand += "\?\r\n"; // resets the buffer from any spurious previous output and send m_UART->rxBufferFlush(); UART_TX(ATCommand); dbgprintf("SEND:\r\n%s",ATCommand.c_str()); if(!WaitFor("OK")){ printf("Error: Missed OK reply - AT+CWMODE\?\r\n"); return -1; } // parsing char ch = m_lastATreply.at(m_lastATreply.find(":") + 1); dbgprintf("WiFi Mode: %c\r\n", ch); testprintf("Ended!\r\n"); return (int8_t) (ch - '0'); }
string Esp8266WiFiPhy::GetSoftAPMac(bool flashStored){ string ATCommand; testprintf("\r\nEntering %s ...", __PRETTY_FUNCTION__); // header ATCommand = "AT+CIPAPMAC_"; // store if (flashStored){ ATCommand += "DEF"; } else { ATCommand += "CUR"; } ATCommand +="\?\r\n"; // resets the buffer from any spurious previous output and send m_UART->rxBufferFlush(); UART_TX(ATCommand); dbgprintf("SEND:\r\n%s",ATCommand.c_str()); if(!WaitFor("OK")){ printf("Error: Missed OK reply - AT+CIPAPMAC\?\r\n"); return ""; } size_t from = 0; string stamac = StringUnescape(GetStringBetweenTokens(':','\r',m_lastATreply, from)); dbgprintf("SoftAP MAC ADDRESS: <%s>\r\n", stamac.c_str()); testprintf("Ended!\r\n"); return stamac; }
void Esp8266WiFiPhy::AutoConnectToStationAtBoot(bool enable){ string ATCommand; testprintf("\r\nEntering %s ...", __PRETTY_FUNCTION__); // header ATCommand = "AT+CWAUTOCONN="; if (enable){ ATCommand += "1"; } else{ ATCommand += "0"; } //tail ATCommand += "\r\n"; // resets the buffer from any spurious previous output and send m_UART->rxBufferFlush(); UART_TX(ATCommand); dbgprintf("SEND:\r\n%s",ATCommand.c_str()); if(!WaitFor("OK")){ printf("Error: AT+CWAUTOCONN! \r\n"); return; } testprintf("Ended!\r\n"); }
StationAccessPoint Esp8266WiFiPhy::GetConnectedStationAP(bool flashStored){ string ATCommand; testprintf("\r\nEntering %s ...", __PRETTY_FUNCTION__); // header ATCommand = "AT+CWJAP_"; if (flashStored){ ATCommand += "DEF"; } else { ATCommand += "CUR"; } ATCommand +="\?\r\n"; // resets the buffer from any spurious previous output and send m_UART->rxBufferFlush(); UART_TX(ATCommand); dbgprintf("SEND:\r\n%s",ATCommand.c_str()); if(!WaitFor("OK")){ printf("Error: Missed OK reply - AT+CWJAP\?\r\n"); return StationAccessPoint("","",""); } size_t from = 0; string ssid = StringUnescape(GetStringBetweenTokens(':',',',m_lastATreply, from)); string bssid = StringUnescape(GetStringBetweenTokens(',',',',m_lastATreply, from)); string channel = GetStringBetweenTokens(',',',',m_lastATreply, from); string rssi = GetStringBetweenTokens(',','\r',m_lastATreply, from); dbgprintf("AccessPoint: <%s>,<%s>,<%s>,<%s>\r\n", ssid.c_str(), bssid.c_str(), channel.c_str(), rssi.c_str()); testprintf("Ended!\r\n"); return StationAccessPoint(ssid,bssid,StringToInteger(channel),StringToInteger(rssi)); }
void Esp8266WiFiPhy::SetWiFiMode(uint8_t mode, bool flashStore){ string ATCommand; testprintf("\r\nEntering %s ...", __PRETTY_FUNCTION__); // header ATCommand = "AT+CWMODE_"; // store if (flashStore){ ATCommand += "DEF"; } else { ATCommand += "CUR"; } ATCommand += "=" + IntegerToString((int)mode); //tail ATCommand += "\r\n"; // resets the buffer from any spurious previous output and send m_UART->rxBufferFlush(); UART_TX(ATCommand); dbgprintf("SEND:\r\n%s",ATCommand.c_str()); if(!WaitFor("OK")){ printf("Error: Missed OK reply - AT+CWMODE_xxx=\r\n"); return; } testprintf("Ended!\r\n"); }
bool CAGuard::WaitUntil(UInt64 inNanos) { bool theAnswer = false; UInt64 theCurrentNanos = CAHostTimeBase::GetCurrentTimeInNanos(); #if Log_TimedWaits DebugMessageN2("CAGuard::WaitUntil: now: %.0f, requested: %.0f", (double)theCurrentNanos, (double)inNanos); #endif if(inNanos > theCurrentNanos) { #if Log_Errors if((inNanos - theCurrentNanos) > 1000000000ULL) { DebugMessage("CAGuard::WaitUntil: about to wait for more than a second"); } #endif theAnswer = WaitFor(inNanos - theCurrentNanos); } else { #if Log_Errors DebugMessageN2("CAGuard::WaitUntil: Time has expired before waiting, now: %.0f, requested: %.0f", (double)theCurrentNanos, (double)inNanos); #endif theAnswer = true; } return theAnswer; }
bool Modem::Setup(){ if(debug) Serial.println("Starting SM5100B Communication..."); serial->begin(9600); // +SIND: 0 SIM card removed // +SIND: 1 SIM card inserted // +SIND: 2 Ring melody // +SIND: 3 AT module is partially ready // +SIND: 4 AT module is totally ready // +SIND: 5 ID of released calls // +SIND: 6 Released call whose ID=<idx> // +SIND: 7 The network service is available for an emergency call // +SIND: 8 The network is lost // +SIND: 9 Audio ON // +SIND: 10 Show the status of each phonebook after init phrase // +SIND: 11 Registered to network if(!WaitFor("+SIND: 4")) return false; delay(1000); if(debug) Serial.println("Modem setup done."); return true; }
void WebHandler::Execute() { CComQIPtr<IHTMLElementCollection> spElementCollection; HRESULT hr = htmlDocument_->get_all(&spElementCollection); //取得表单集合 if (FAILED(hr)) return; auto loginLabel = GetElement(spElementCollection, L"id", L"fxLogin"); if (!loginLabel) return; loginLabel->click(); WaitFor(50); auto username = GetElement(spElementCollection, L"name", L"username"); if (username) { username->click(); username->put_innerText(L"jordanlsw"); } auto password = GetElement(spElementCollection, L"name", L"password"); if (password) { password->click(); password->put_innerText(L"123123"); } auto login_btn = GetElement(spElementCollection, L"name", L"login_btn"); if (login_btn) { login_btn->click(); } }
void WebHandler::Login(const CString& userName, const CString& pwd) { CComQIPtr<IHTMLElementCollection> spElementCollection; HRESULT hr = htmlDocument_->get_all(&spElementCollection); //取得表单集合 if (FAILED(hr)) return; auto loginLabel = GetElement(spElementCollection, L"id", L"fxLogin"); if (!loginLabel) return; loginLabel->click(); WaitFor(50); auto username = GetElement(spElementCollection, L"name", L"username"); if (username) { username->click(); CString temp = userName; username->put_innerText(temp.GetBuffer()); } auto password = GetElement(spElementCollection, L"name", L"password"); if (password) { password->click(); CString temp = pwd; password->put_innerText(temp.GetBuffer()); } auto login_btn = GetElement(spElementCollection, L"name", L"login_btn"); if (login_btn) { login_btn->click(); } }
/*#$% ============================================================== 通信回線をクローズする -------------------------------------------------------------- -------------------------------------------------------------- -------------------------------------------------------------- ============================================================== */ void __fastcall CComm::Close(void) { if( m_CreateON == TRUE ){ if( m_Execute ){ m_TxEnb = 0; m_Command = COMM_CLOSE; // スレッド終了コマンド Priority = tpNormal; //スレッドは通常の優先度である #if 0 DWORD tim = GetTickCount(); while( m_Command && (GetTickCount() < (tim + 3000)) ){ // スレッド終了待ち ::Sleep(1); } #else WaitFor(); #endif FSKCount1+=1000; } if( m_pEXT != NULL ){ delete m_pEXT; m_pEXT = NULL; } else { ::CloseHandle(m_fHnd); } m_CreateON = FALSE; } }
ServerThread::~ServerThread() { #ifdef _WIN32 DeleteCriticalSection(&csServerThread); #else if(threadId != 0) { Close(); WaitFor(); } pthread_mutex_destroy(&mtxServerThread); #endif AntiConFlood *acfnext = AntiFloodList; while(acfnext != NULL) { AntiConFlood *acfcur = acfnext; acfnext = acfcur->next; delete acfcur; } #ifdef _WIN32 if(threadHandle != INVALID_HANDLE_VALUE) { CloseHandle(threadHandle); } #endif }
/** Receive data on a socket via RecvFrom @param aSocket The socket to recevie data from @param aDesc Descriptor to receive the data into @param anAddress On success, contains the address from which data was received @return ETrue on success, EFalse on failure */ TBool CEsockTest9_6::PerformRecv( RSocket& aSocket, TDes8& aDesc, TSockAddr& anAddress ) { TRequestStatus socketStatus; aSocket.RecvFrom( aDesc, anAddress, 0, socketStatus ); WaitFor( socketStatus, KTimerPeriod ); Logger().WriteFormat(_L("UDP Recv returns %d"), socketStatus.Int() ); if( socketStatus == KRequestPending ) { aSocket.CancelRecv(); Logger().WriteFormat(_L("Timeout on UDP Recv")); User::WaitForRequest( socketStatus ); return EFalse; } if( socketStatus != KErrNone ) { Logger().WriteFormat(_L("UDP Recv failed with error %d"), socketStatus.Int() ); return EFalse; } return ETrue; }
TEST_F(BasicThreadTest, ValidateThreadTimes) { AutoCurrentContext ctxt; ctxt->Initiate(); static const size_t spinCount = 10000000; auto spinsThenQuits = ctxt->Construct<SpinsAndThenQuits>(spinCount); // Instantaneous benchmark on the time it takes to decrement the counter value: std::chrono::nanoseconds benchmark; { auto startTime = std::chrono::high_resolution_clock::now(); for(volatile size_t i = spinCount; i--;); benchmark = std::chrono::high_resolution_clock::now() - startTime; } // By this point, not much should have happened: std::chrono::milliseconds kernelTime; std::chrono::milliseconds userTime; spinsThenQuits->GetThreadTimes(kernelTime, userTime); // Kick off the thread and wait for it to exit: spinsThenQuits->Continue(); ASSERT_TRUE(spinsThenQuits->WaitFor(std::chrono::seconds(10))) << "Spin-then-quit test took too long to execute"; // Thread should not have been able to complete in less time than we completed, by a factor of ten or so at least ASSERT_LE(benchmark, spinsThenQuits->m_userTime * 10) << "Reported execution time could not possibly be correct, spin operation took less time to execute than should have been possible with the CPU"; }
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int nCmdShow) { MSG msg; game = new Game(&backHDC, &frontHDC, &bitmapHDC, &screenRect, &CONTROLS); RegisterMyWindow(hInstance); if (!InitialiseMyWindow(hInstance, nCmdShow)) return FALSE; setBuffers(); while (TRUE) { if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { if (msg.message==WM_QUIT) break; TranslateMessage (&msg); DispatchMessage (&msg); } else { if(WaitFor(10)) game->play(); } } releaseResources(); return msg.wParam ; }
/*#$% ============================================================== 通信回線をクローズする -------------------------------------------------------------- -------------------------------------------------------------- -------------------------------------------------------------- スレッドが終了するまで待つ ============================================================== */ void __fastcall CCradio::Close(void) { if( m_CreateON == TRUE ){ if( m_PSKGNRId ){ if( (m_OpenGNR || RADIO.change) && RADIO.openGNR ) ::SendMessage(HWND_BROADCAST, m_PSKGNRId, 1 , 0); m_PSKGNRId = 0; } else { if( m_ID ){ m_Command = CRADIO_CLOSE; // スレッド終了コマンド Priority = tpNormal; //スレッドは通常の優先度である WaitFor(); } if( m_pRadio != NULL ){ delete m_pRadio; m_pRadio = NULL; } else { ::CloseHandle(m_fHnd); } } } m_CreateON = FALSE; m_TxAbort = TRUE; }
//--------------------------------------------------------------------------- tTVPWatchThread::~tTVPWatchThread() { Terminate(); Resume(); Event.Set(); WaitFor(); }
void FileUpload::Execute() { if (HasRequest() && mState != eClient_STATE_CONNECTED) // 有上传请求 && 尚未连接 { TryConnectServer(); } if (mState == eClient_STATE_CONNECTED) // 已连接上 { //if (CanSendData()) { UploadRequest* Req = PopRequest(); if (Req) { if (HandleRequest(Req)) { // Req已放入WaitingList, 暂不回收 } else { AddResponse(*Req, false, ""); delete Req; } } } if (CanRecvData() && mRecvSize < MAX_RECV_BUFF_SIZE) { int Ret = recv(mSocket, &mRecvBuff[mRecvSize], MAX_RECV_BUFF_SIZE - mRecvSize, 0); if (Ret == SOCKET_ERROR || Ret <= 0) { CloseSocket(eClient_STATE_ABORT, true); // TODO: 当服务器send主动关闭时 (应该至少还能recv一次, 没问题) } else { mRecvSize += Ret; } } } ServerResponse SrvRep; if (TryDecodeRecvBuff(SrvRep)) { auto Itr = mWaitingList.find(SrvRep.mSrvFileName); if (Itr != mWaitingList.end()) { auto Req = Itr->second; if (Req) { AddResponse(*Req, SrvRep.mFlag == 0x00A2, SrvRep.mSrvFileName); delete Req; } mWaitingList.erase(Itr); } } WaitFor(1); }
//--------------------------------------------------------------------------- tTVPTimerThread::~tTVPTimerThread() { Terminate(); Resume(); Event.Set(); WaitFor(); EventQueue.Deallocate(); }
status_t ResolveValueNodeValueJob::_ResolveParentNodeValue(ValueNode* parentNode) { AutoLocker<ValueNodeContainer> containerLocker(fContainer); if (parentNode->Container() != fContainer) return B_BAD_VALUE; // if the parent node already has a value, we're done status_t nodeResolutionState = parentNode->LocationAndValueResolutionState(); if (nodeResolutionState != VALUE_NODE_UNRESOLVED) return nodeResolutionState; // check whether a job is already in progress AutoLocker<Worker> workerLocker(GetWorker()); SimpleJobKey jobKey(parentNode, JOB_TYPE_RESOLVE_VALUE_NODE_VALUE); if (GetWorker()->GetJob(jobKey) == NULL) { workerLocker.Unlock(); // schedule the job status_t error = GetWorker()->ScheduleJob( new(std::nothrow) ResolveValueNodeValueJob(fDebuggerInterface, fArchitecture, fCpuState, fTypeInformation, fContainer, parentNode)); if (error != B_OK) { // scheduling failed -- set the value to invalid parentNode->SetLocationAndValue(NULL, NULL, error); return error; } } // wait for the job to finish workerLocker.Unlock(); containerLocker.Unlock(); switch (WaitFor(jobKey)) { case JOB_DEPENDENCY_SUCCEEDED: case JOB_DEPENDENCY_NOT_FOUND: // "Not found" can happen due to a race condition between // unlocking the worker and starting to wait. break; case JOB_DEPENDENCY_ACTIVE: return B_OK; case JOB_DEPENDENCY_FAILED: case JOB_DEPENDENCY_ABORTED: default: return B_ERROR; } containerLocker.Lock(); // now there should be a value for the node nodeResolutionState = parentNode->LocationAndValueResolutionState(); return nodeResolutionState != VALUE_NODE_UNRESOLVED ? nodeResolutionState : B_ERROR; }
CThread::~CThread() { // If the thread is still running. if (m_nThreadId != 0 && !m_bFinished) { Terminate(); WaitFor(); } if (m_nThreadId != 0) CloseHandle(m_hHandle); }
/* ================ rvDebuggerClient::HandleBreak Handle the DBMSG_BREAK message send from the server. This message is handled by caching the file and linenumber where the break occured. ================ */ void rvDebuggerClient::HandleBreak ( msg_t* msg ) { char filename[MAX_PATH]; mBreak = true; // Line number mBreakLineNumber = MSG_ReadLong ( msg ); // Filename MSG_ReadString ( msg, filename, MAX_PATH ); mBreakFilename = filename; // Clear the variables mVariables.Clear ( ); // Request the callstack and threads SendMessage ( DBMSG_INSPECTCALLSTACK ); WaitFor ( DBMSG_INSPECTCALLSTACK, 2000 ); SendMessage ( DBMSG_INSPECTTHREADS ); WaitFor ( DBMSG_INSPECTTHREADS, 2000 ); }
// Windows with Windows-style times void PCondVar::WaitUntil(PLock *pLock, const FILETIME *time) { FILETIME now; GetSystemTimeAsFileTime(&now); LARGE_INTEGER liNow, liTime; liNow.HighPart = now.dwHighDateTime; liNow.LowPart = now.dwLowDateTime; liTime.HighPart = time->dwHighDateTime; liTime.LowPart = time->dwLowDateTime; if (liNow.QuadPart >= liTime.QuadPart) // Already past the time return; DWORD toWait = (DWORD)((liTime.QuadPart - liNow.QuadPart) / (LONGLONG)10000); (void)WaitFor(pLock, toWait); }
// Unix-style times void PCondVar::WaitUntil(PLock *pLock, const timespec *time) { #ifdef HAVE_PTHREAD pthread_cond_timedwait(&cond, &pLock->lock, time); #elif defined(HAVE_WINDOWS_H) // This must be Cygwin but compiled with --without-threads struct timeval tv; if (gettimeofday(&tv, NULL) != 0) return; if (tv.tv_sec > time->tv_sec || (tv.tv_sec == time->tv_sec && tv.tv_usec >= time->tv_nsec/1000)) return; // Already past the time WaitFor(pLock, (time->tv_sec - tv.tv_sec) * 1000 + time->tv_nsec/1000000 - tv.tv_usec/1000); #endif }
tTVPAsyncImageLoader::~tTVPAsyncImageLoader() { ExitRequest(); WaitFor(); EventQueue.Deallocate(); while( CommandQueue.size() > 0 ) { tTVPImageLoadCommand* cmd = CommandQueue.front(); CommandQueue.pop(); delete cmd; } while( LoadedQueue.size() > 0 ) { tTVPImageLoadCommand* cmd = LoadedQueue.front(); LoadedQueue.pop(); delete cmd; } }