Ejemplo n.º 1
0
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;
		}
	}
}
Ejemplo n.º 2
0
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");
}
Ejemplo n.º 3
0
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 );
		}
	}
}
Ejemplo n.º 4
0
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;
	}
}
Ejemplo n.º 5
0
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);
	}
}
Ejemplo n.º 6
0
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);
	}
}
Ejemplo n.º 7
0
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");
}
Ejemplo n.º 8
0
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;
}
Ejemplo n.º 9
0
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();
}
Ejemplo n.º 10
0
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");
}
Ejemplo n.º 11
0
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");
}
Ejemplo n.º 12
0
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);
    }
}
Ejemplo n.º 13
0
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");
}
Ejemplo n.º 14
0
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");
}
Ejemplo n.º 15
0
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;
        }
        
    }

}
Ejemplo n.º 16
0
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);
}
Ejemplo n.º 17
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();
}
Ejemplo n.º 18
0
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);
				}
			}
		}
	}
}
Ejemplo n.º 19
0
HRESULT
CTransformInputPin::BreakConnect() {
    //  Can't disconnect unless stopped
    ASSERT(IsStopped());
    m_pTransformFilter->BreakConnect(PINDIR_INPUT);
    return CBaseInputPin::BreakConnect();
}
Ejemplo n.º 20
0
HRESULT CAMROutputPin::BreakConnect()
{
	ASSERT(IsStopped());
	demux->BreakConnect(PINDIR_OUTPUT, this);
	discontinuity = true;
	return CBaseOutputPin::BreakConnect();
}
Ejemplo n.º 21
0
	bool Source::IsStopped() const
	{
	    #ifdef HAS_AUDIO_SOURCE
		return impl->IsStopped();
		#else
		throw System::PunkException(L"Audio source is not available");
		#endif
	}
Ejemplo n.º 22
0
 void Run(void* ptr)
 {
     while(!IsStopped())
     {
         std::cout << "Running..." << std::endl;
         m_signal.WaitSignal(1000);
     }
 }
Ejemplo n.º 23
0
HRESULT CSubtitleInputPin::BreakConnect()
{
    RemoveSubStream(m_pSubStream);
    m_pSubStream = NULL;

    ASSERT(IsStopped());

    return __super::BreakConnect();
}
Ejemplo n.º 24
0
    bool UpdateMicroTimer(uint64_t micro)
    {
      LogAssert(m_scheduler->IsMainThread());

      if (IsStopped())
        return SetMicroTimer(micro);

      return setExpireTime(m_startTime, micro);
    }
Ejemplo n.º 25
0
void NServFrontend::Run()
{
	while (!IsStopped())
	{
		Update();
		usleep(100 * 1000);
	}
	// Printing the last messages
	Update();
}
Ejemplo n.º 26
0
// 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 );
	}
}
Ejemplo n.º 27
0
/// 关闭音频采集设备
void CAudioCapture::Close(void)
{
	if(!IsStopped())
		Stop();

	SAFE_RELEASE(m_pCaptureFilter);
	SAFE_RELEASE(m_pAudioReander);
	SAFE_RELEASE(m_pCGBuilder);

	DestroyGraphBuilder();
}
Ejemplo n.º 28
0
HRESULT CSubtitleInputPin::BreakConnect()
{
    InvalidateSamples();

    RemoveSubStream(m_pSubStream);
    m_pSubStream = nullptr;

    ASSERT(IsStopped());

    return __super::BreakConnect();
}
Ejemplo n.º 29
0
/// 关闭
void CAudioPlayer::Close(void)
{
	if(!IsStopped())
		Stop();

	SAFE_RELEASE(m_pAudioCapture);
	SAFE_RELEASE(m_pAudioRender);
	SAFE_RELEASE(m_pBasicAudio);

	DestroyGraphBuilder();
}
Ejemplo n.º 30
0
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;
}