void ArticleCache::Run() { // automatically flush the cache if it is filled to 90% (only in DirectWrite mode) size_t fillThreshold = (size_t)g_Options->GetArticleCache() * 1024 * 1024 / 100 * 90; int resetCounter = 0; bool justFlushed = false; while (!IsStopped() || m_allocated > 0) { if ((justFlushed || resetCounter >= 1000 || IsStopped() || (g_Options->GetDirectWrite() && m_allocated >= fillThreshold)) && m_allocated > 0) { justFlushed = CheckFlush(m_allocated >= fillThreshold); resetCounter = 0; } else if (!m_allocated) { Guard guard(m_allocMutex); m_allocCond.Wait(m_allocMutex, [&]{ return IsStopped() || m_allocated > 0; }); resetCounter = 0; } else { Util::Sleep(5); resetCounter += 5; } } }
void NntpServer::Run() { debug("Entering NntpServer-loop"); info("Listening on port %i", m_port); #ifdef WIN32 if (m_speed > 0) { timeBeginPeriod(1); } #endif int num = 1; while (!IsStopped()) { bool bind = true; if (!m_connection) { m_connection = std::make_unique<Connection>(m_host, m_port, m_secureCert); m_connection->SetTimeout(10); m_connection->SetSuppressErrors(false); bind = m_connection->Bind(); } // Accept connections and store the new Connection std::unique_ptr<Connection> acceptedConnection; if (bind) { acceptedConnection = m_connection->Accept(); } if (!bind || !acceptedConnection) { // Server could not bind or accept connection, waiting 1/2 sec and try again if (IsStopped()) { break; } m_connection.reset(); usleep(500 * 1000); continue; } NntpProcessor* commandThread = new NntpProcessor(num++, m_id, m_dataDir, m_cacheDir, m_secureCert, m_secureKey, m_latency, m_speed, m_cache); commandThread->SetAutoDestroy(true); commandThread->SetConnection(std::move(acceptedConnection)); commandThread->Start(); } if (m_connection) { m_connection->Disconnect(); } debug("Exiting NntpServer-loop"); }
void CSoldierBase::MoveCommon() { //目標地点へ移動(中腰) if( m_sTargetPosition < m_sPositionX ) //+800 { m_sMoveX = -4; m_sDir = DIR_LEFT; if( IsStopped() && IsLanding() ) { // if( pGame->pBg->get_kabetype(m_pObj->pos.x/100-0*1,m_pObj->pos.y/100) == 0 // && viiSub::IsGroundBlock(m_pObj->pos.x/100-0*1,m_pObj->pos.y/100) ) if( pGame->pBg->get_kabetype(m_pObj->pos.x/100-1*1,m_pObj->pos.y/100-8*0) == 1 && pGame->pBg->get_kabetype(m_pObj->pos.x/100-1*1,m_pObj->pos.y/100-8*1) == 1 && pGame->pBg->get_kabetype(m_pObj->pos.x/100-1*1,m_pObj->pos.y/100-8*2) == 0 ) { //壁がなければジャンプさせる ChangeMoveType( enMoveTypeClimb ); //SetJump(); } } } else if( m_sTargetPosition > m_sPositionX ) //-800 { m_sMoveX = +4; m_sDir = DIR_RIGHT; if( IsStopped() && IsLanding() ) { // if( pGame->pBg->get_kabetype(m_pObj->pos.x/100+8*1,m_pObj->pos.y/100-16) == 0 // && viiSub::IsGroundBlock(m_pObj->pos.x/100+8*1,m_pObj->pos.y/100) ) if( pGame->pBg->get_kabetype(m_pObj->pos.x/100+1*1,m_pObj->pos.y/100-8*0) == 1 && pGame->pBg->get_kabetype(m_pObj->pos.x/100+1*1,m_pObj->pos.y/100-8*1) == 1 && pGame->pBg->get_kabetype(m_pObj->pos.x/100+1*1,m_pObj->pos.y/100-8*2) == 0) { //壁がなければジャンプさせる ChangeMoveType( enMoveTypeClimb ); // SetJump(); } } } else { m_sMoveX = 0; if( MoveSpeedDecrement() ) { ChangeMoveType( enMoveTypeWait ); } } }
void WINAPI CTNTServer::OnReceive(const CONNECTION_ID& Connection, const LPVOID pData, const DWORD dwDataLen) { CFixBuffer& InputStream = m_mapPeers[Connection.m_Socket].m_InputStream; InputStream.Put(pData, dwDataLen); while(true) { // is there a room for MsgSize? if(InputStream.GetLength() < MESSAGE_HEADER_SIZE) return; CString strSize; char* pSizeString = strSize.GetBufferSetLength(4); memcpy(pSizeString,((char*)InputStream.GetData() + sizeof(char)*25),3); pSizeString[3]=0; strSize.ReleaseBuffer(); DWORD dwSize = (DWORD)atol(strSize); // is there a room for Msg? if(InputStream.GetLength() < dwSize) return; for(COMMANDS_TYPE::iterator index = m_ValidIncomingCommands.begin(); index != m_ValidIncomingCommands.end(); index++) { CMMHHMessage* pitem= *index; if(pitem->Parse(InputStream) == ERROR_SUCCESS) { CMessageItem Item; if(IsStopped()) break; Item.m_pMessage = pitem->GetNewCopy(); TMapPeers::iterator it = m_mapPeers.find(Connection.m_Socket); if(it == m_mapPeers.end()) { ATLASSERT(false); return; } Item.m_Client = it->first; m_queIncoming.Push(Item); break; } } if(IsStopped()) return; } }
void ChildWatchDog::Run() { static const int WAIT_SECONDS = 60; time_t start = Util::CurrentTime(); while (!IsStopped() && (Util::CurrentTime() - start) < WAIT_SECONDS) { Util::Sleep(10); } if (!IsStopped()) { info("Restarting hanging child process for %s", *m_infoName); kill(m_processId, SIGKILL); } }
void ChildWatchDog::Run() { static const int WAIT_SECONDS = 60; time_t tStart = time(NULL); while (!IsStopped() && (time(NULL) - tStart) < WAIT_SECONDS) { usleep(10 * 1000); } if (!IsStopped()) { info("Restarting hanging child process"); kill(m_hProcessID, SIGKILL); } }
void UrlCoordinator::Run() { debug("Entering UrlCoordinator-loop"); while (!DownloadQueue::IsLoaded()) { usleep(20 * 1000); } int resetCounter = 0; while (!IsStopped()) { bool downloadStarted = false; if (!g_Options->GetPauseDownload() || g_Options->GetUrlForce()) { // start download for next URL GuardedDownloadQueue downloadQueue = DownloadQueue::Guard(); if ((int)m_activeDownloads.size() < g_Options->GetUrlConnections()) { NzbInfo* nzbInfo = GetNextUrl(downloadQueue); bool hasMoreUrls = nzbInfo != nullptr; bool urlDownloadsRunning = !m_activeDownloads.empty(); m_hasMoreJobs = hasMoreUrls || urlDownloadsRunning; if (hasMoreUrls && !IsStopped()) { StartUrlDownload(nzbInfo); downloadStarted = true; } } } int sleepInterval = downloadStarted ? 0 : 100; usleep(sleepInterval * 1000); resetCounter += sleepInterval; if (resetCounter >= 1000) { // this code should not be called too often, once per second is OK ResetHangingDownloads(); resetCounter = 0; } } WaitJobs(); debug("Exiting UrlCoordinator-loop"); }
uint32_t plLayerMovie::Eval(double wSecs, uint32_t frame, uint32_t ignore) { uint32_t dirty = plLayerAnimation::Eval(wSecs, frame, ignore); if( !IGetFault() && !(ignore & kTexture) ) { if( ICurrentFrameDirty(wSecs) ) { if( IGetCurrentFrame() ) ISetFault("Getting current frame"); if( GetTexture() ) { hsGDeviceRef* ref = GetTexture()->GetDeviceRef(); if( ref ) ref->SetDirty(true); } } else if( IsStopped() ) { IMovieIsIdle(); } dirty |= kTexture; } return dirty; }
void TestCommonData::Wait( bool& work, bool& done) { work = false; done = false; bool started = false; while( !done || !started ) { if (work) started = true; UpdateData(); if ( IsStopped() ) { mCommand.Start_Oper = false; mCommand.Stop_Oper = true; mCommand.Nasos_M2 = app::Settings::Instance().MainPupm() == "M2"; mCommand.OP15_25_Continum = false; mCommand.Next_Amp = false; mCommand.Write(); Log( "Испытание прервано" ); return; } } TestingTime = StartTime.elapsed()/1000; *mStopMarker = !CheckErrors(); }
void ServiceCoordinator::Run() { debug("Entering ServiceCoordinator-loop"); const int iStepMSec = 100; int iCurTick = 0; while (!IsStopped()) { for (ServiceList::iterator it = m_Services.begin(); it != m_Services.end(); it++) { Service* pService = *it; if (iCurTick >= pService->m_iLastTick + pService->ServiceInterval() || // interval expired iCurTick == 0 || // first start iCurTick + 10000 < pService->m_iLastTick) // int overflow { pService->ServiceWork(); pService->m_iLastTick = iCurTick; } } iCurTick += iStepMSec; usleep(iStepMSec * 1000); } debug("Exiting ServiceCoordinator-loop"); }
void PrePostProcessor::Run() { debug("Entering PrePostProcessor-loop"); while (!DownloadQueue::IsLoaded()) { usleep(20 * 1000); } if (g_Options->GetServerMode() && g_Options->GetSaveQueue() && g_Options->GetReloadQueue()) { SanitisePostQueue(); } while (!IsStopped()) { if (!g_Options->GetTempPausePostprocess()) { // check post-queue every 200 msec CheckPostQueue(); } Util::SetStandByMode(!m_curJob); usleep(200 * 1000); } debug("Exiting PrePostProcessor-loop"); }
void Creature::setDeathState(DeathState s) { if(s == JUST_DIED) { m_deathTimer = m_corpseDelay*1000; // always save boss respawn time at death to prevent crash cheating if(sWorld.getConfig(CONFIG_SAVE_RESPAWN_TIME_IMMEDIATLY) || isWorldBoss()) SaveRespawnTime(); if(!IsStopped()) StopMoving(); } Unit::setDeathState(s); if(s == JUST_DIED) { SetUInt32Value(UNIT_NPC_FLAGS, 0); if(!isPet() && GetCreatureInfo()->SkinLootId) { LootStore skinStore = LootTemplates_Skinning; LootStore::iterator tab = skinStore.find(GetCreatureInfo()->SkinLootId); if ( tab != skinStore.end() ) SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE); } Unit::setDeathState(CORPSE); } }
void ServiceCoordinator::Run() { debug("Entering ServiceCoordinator-loop"); const int stepMSec = 100; int curTick = 0; while (!IsStopped()) { for (Service* service : m_services) { if (curTick >= service->m_lastTick + service->ServiceInterval() || // interval expired curTick == 0 || // first start curTick + 10000 < service->m_lastTick) // int overflow { service->ServiceWork(); service->m_lastTick = curTick; } } curTick += stepMSec; usleep(stepMSec * 1000); } debug("Exiting ServiceCoordinator-loop"); }
void PrePostProcessor::Run() { debug("Entering PrePostProcessor-loop"); while (!DownloadQueue::IsLoaded()) { usleep(20 * 1000); } if (g_Options->GetServerMode()) { SanitisePostQueue(); } while (!IsStopped()) { if (!g_Options->GetTempPausePostprocess() && m_queuedJobs) { // check post-queue every 200 msec CheckPostQueue(); } usleep(200 * 1000); } WaitJobs(); debug("Exiting PrePostProcessor-loop"); }
void Train::Update(const sf::Input &input) { static sf::Clock clock; static bool waiting = false; acceleration = (1/mass) *(push_force - speed * brakes_factor); speed += acceleration; position.z += speed; if (position.z > 900 || position.z < -900) { position.z = -position.z; //comingSound.SetPosition(this->position); comingSound.Play(); StopGas(); } if (!user_controlled){ if (position.z < -250 && position.z > -300){ StopGas(); Brakes(); } if (IsStopped() && !waiting){ clock.Reset(); alarm=false; waiting = true; printf("\n\n\n waiting\n"); } if (waiting && clock.GetElapsedTime() > waiting_time) { Gas(); waiting = false; printf(" timed out\n"); } if (waiting && clock.GetElapsedTime() > waiting_time-4 && !alarm) { alarm=true; sound.SetBuffer(Buffer); //sound.SetPitch(0.6); //sound.SetAttenuation(0.4); sound.SetRelativeToListener(true); sound.SetPosition(this->position); sound.SetMinDistance(100); sound.Play(); //movmetnSound.SetPosition(this->position); movmetnSound.Play(); } light->position = sf::Vector3f(-40.900002,10,position.z + 5) ; if(camera !=NULL) camera->SetOrigin(position.x+8.3,position.y+15,position.z); }else { if (input.IsKeyDown(sf::Key::Z)) { push_force = 0.1f; }else if (input.IsKeyDown(sf::Key::X)){ brakes_factor = 0.05f; } } }
int CScionCamera::SequenceThread::svc() { long count(0); // capture requested number of images while (!IsStopped() && count < numImages_) { // get next image int ret = camera_->SnapImage(); if (ret != DEVICE_OK) { camera_->sequenceRunning_ = false; camera_->OnThreadExiting(); return(1); } // got image - insert image in micro manager buffer pool ret = camera_->InsertImage(); if (ret != DEVICE_OK) { camera_->sequenceRunning_ = false; camera_->OnThreadExiting(); return(1); } camera_->image_counter_++; count++; } // sequence complete camera_->OnThreadExiting(); camera_->sequenceRunning_ = false; return(0); }
// provides derived filter a chance to release it's extra interfaces HRESULT CParserOutputPin::BreakConnect() { // Can't disconnect unless stopped ASSERT(IsStopped()); m_pTransformFilter->BreakConnect(PINDIR_OUTPUT); return CBaseOutputPin::BreakConnect(); }
void ParRenamer::CheckFiles(const char* destDir, bool checkPars) { DirBrowser dir(destDir); while (const char* filename = dir.Next()) { if (!IsStopped()) { BString<1024> fullFilename("%s%c%s", destDir, PATH_SEPARATOR, filename); if (!FileSystem::DirectoryExists(fullFilename)) { m_progressLabel.Format("Checking file %s", filename); m_stageProgress = m_fileCount > 0 ? m_curFile * 1000 / m_fileCount / 2 : 1000; UpdateProgress(); m_curFile++; if (checkPars) { CheckParFile(destDir, fullFilename); } else { CheckRegularFile(destDir, fullFilename); } } } } }
HRESULT CTransformInputPin::BreakConnect() { // Can't disconnect unless stopped ASSERT(IsStopped()); m_pTransformFilter->BreakConnect(PINDIR_INPUT); return CBaseInputPin::BreakConnect(); }
HRESULT CAMROutputPin::BreakConnect() { ASSERT(IsStopped()); demux->BreakConnect(PINDIR_OUTPUT, this); discontinuity = true; return CBaseOutputPin::BreakConnect(); }
bool Source::IsStopped() const { #ifdef HAS_AUDIO_SOURCE return impl->IsStopped(); #else throw System::PunkException(L"Audio source is not available"); #endif }
void Run(void* ptr) { while(!IsStopped()) { std::cout << "Running..." << std::endl; m_signal.WaitSignal(1000); } }
HRESULT CSubtitleInputPin::BreakConnect() { RemoveSubStream(m_pSubStream); m_pSubStream = NULL; ASSERT(IsStopped()); return __super::BreakConnect(); }
bool UpdateMicroTimer(uint64_t micro) { LogAssert(m_scheduler->IsMainThread()); if (IsStopped()) return SetMicroTimer(micro); return setExpireTime(m_startTime, micro); }
void NServFrontend::Run() { while (!IsStopped()) { Update(); usleep(100 * 1000); } // Printing the last messages Update(); }
// Use all FILES in output dir to upload, not just the written files. void ResetUploadReportQueue( char *reportLocation ) { if ( gFopenHistoryPtr && !IsStopped() ) { char sourcepath[256]; PathFromFullPath( reportLocation, sourcepath ); DateFixFilename( sourcepath, 0 ); AddWildCardReportFiles( sourcepath ); } }
/// 关闭音频采集设备 void CAudioCapture::Close(void) { if(!IsStopped()) Stop(); SAFE_RELEASE(m_pCaptureFilter); SAFE_RELEASE(m_pAudioReander); SAFE_RELEASE(m_pCGBuilder); DestroyGraphBuilder(); }
HRESULT CSubtitleInputPin::BreakConnect() { InvalidateSamples(); RemoveSubStream(m_pSubStream); m_pSubStream = nullptr; ASSERT(IsStopped()); return __super::BreakConnect(); }
/// 关闭 void CAudioPlayer::Close(void) { if(!IsStopped()) Stop(); SAFE_RELEASE(m_pAudioCapture); SAFE_RELEASE(m_pAudioRender); SAFE_RELEASE(m_pBasicAudio); DestroyGraphBuilder(); }
void PythonDebugger::OnValueTooltip(CodeBlocksEvent& event) { event.Skip(); if (!m_DebuggerActive) return; if (!IsStopped()) return; EditorBase* base = event.GetEditor(); cbEditor* ed = base && base->IsBuiltinEditor() ? static_cast<cbEditor*>(base) : 0; if (!ed) return; if(ed->IsContextMenuOpened()) { return; } // get rid of other calltips (if any) [for example the code completion one, at this time we // want the debugger value call/tool-tip to win and be shown] if(ed->GetControl()->CallTipActive()) { ed->GetControl()->CallTipCancel(); } const int style = event.GetInt(); if (style != wxSCI_P_DEFAULT && style != wxSCI_P_OPERATOR && style != wxSCI_P_IDENTIFIER && style != wxSCI_P_CLASSNAME) return; wxPoint pt; pt.x = event.GetX(); pt.y = event.GetY(); int pos = ed->GetControl()->PositionFromPoint(pt); int start = ed->GetControl()->WordStartPosition(pos, true); int end = ed->GetControl()->WordEndPosition(pos, true); while(ed->GetControl()->GetCharAt(start-1)==_T('.')) start=ed->GetControl()->WordStartPosition(start-2, true); wxString token; if (start >= ed->GetControl()->GetSelectionStart() && end <= ed->GetControl()->GetSelectionEnd()) { token = ed->GetControl()->GetSelectedText(); } else token = ed->GetControl()->GetTextRange(start,end); if (token.IsEmpty()) return; wxString cmd; cmd+=_T("pw ")+token+_T("\n"); DispatchCommands(cmd,DBGCMDTYPE_WATCHTOOLTIP,true); m_watch_tooltip_pos=pos; }