Exemplo n.º 1
0
Arquivo: job.cpp Projeto: PyroOS/Pyro
void UploadJob::HandleOverwriteReply( Message* pcMsg )
{
	int nResponse;
	bool bPersistent = false;
	pcMsg->FindInt32( "userResponse", &nResponse );
	pcMsg->FindBool( "persistent", &bPersistent );
	if( nResponse == RESPONSE_YES ) {
		if( bPersistent ) SetOverwritePolicy( OP_OVERWRITE );
		Resume();
	} else if( nResponse == RESPONSE_NO ) {
		if( bPersistent ) SetOverwritePolicy( OP_SKIP );
		m_nStatus = STATUS_SKIPPED;
		FinaliseJob();
		if( m_pcParent ) m_pcParent->ChildTransferFinished( NULL, -1, this );
	}
	else DEBUG("UploadJob::HandleOverwriteReply: Got unexpected response %i!\n", nResponse );
}
Exemplo n.º 2
0
/// <summary>
/// Get WOW64 thread context
/// </summary>
/// <param name="ctx">Returned context</param>
/// <param name="flags">Context flags.</param>
/// <param name="dontSuspend">true if thread shouldn't be suspended before retrieving context</param>
/// <returns>true on success</returns>
bool Thread::GetContext( _CONTEXT32& ctx, DWORD flags /*= CONTEXT_ALL*/, bool dontSuspend /*= false*/ )
{
    bool result = false;

    memset( &ctx, 0x00, sizeof(ctx) );
    ctx.ContextFlags = flags;

    if (dontSuspend || Suspend())
    {
        result = (_core->native()->GetThreadContextT( _handle, ctx ) == STATUS_SUCCESS);

        if (!dontSuspend)
            Resume();
    }
        
    return result;
}
void
nsSMILTimeContainer::Begin()
{
  Resume(PAUSE_BEGIN);
  if (mPauseState) {
    mNeedsPauseSample = PR_TRUE;
  }

  // This is a little bit complicated here. Ideally we'd just like to call
  // Sample() and force an initial sample but this turns out to be a bad idea
  // because this may mean that NeedsSample() no longer reports true and so when
  // we come to the first real sample our parent will skip us over altogether.
  // So we force the time to be updated and adopt the policy to never call
  // Sample() ourselves but to always leave that to our parent or client.

  UpdateCurrentTime();
}
Exemplo n.º 4
0
// SetTo
bool
NameIndexEntryIterator::SetTo(NameIndex *index, const char *name,
							  bool ignoreValue)
{
	Resume();
	fIndex = index;
	fSuspended = false;
	fIsNext = false;
	if (fIndex) {
		if (ignoreValue) {
			fIndex->fEntries->GetIterator(&fIterator);
			return fIterator.GetCurrent();
		}
		return fIndex->fEntries->FindFirst(name, &fIterator);
	}
	return false;
}
Exemplo n.º 5
0
HRESULT CWinThread::CreateNoCRT( IWinRunnable* piRunnable )
{
	assert(!m_h);
	assert(piRunnable);
	if (m_h)
		return AtlHresultFromWin32(ERROR_ALREADY_INITIALIZED);

	if (!piRunnable)
		return E_POINTER;

	m_h = ::CreateThread(NULL, 0, RunThreadFuncNoCRT, piRunnable, CREATE_SUSPENDED, NULL);
	if (!m_h)
		return GetLastError() ? AtlHresultFromLastError() : E_FAIL;

	Resume();
	return S_OK;
}
Exemplo n.º 6
0
bool
Start()
{
  if (gSession) {
    return false;
  }

  if (!LoadDTPerformanceLibrary()) {
    return false;
  }

  AutoReleased<CFStringRef> process =
    CFStringCreateWithFormat(kCFAllocatorDefault, nullptr, CFSTR("%d"),
                             getpid());
  if (!process) {
    return false;
  }
  CFErrorRef error = nullptr;
  gSession = DTPerformanceSessionCreate(nullptr, process, nullptr, &error);
  if (!gSession) {
    return Error(error);
  }

  AutoReleased<CFNumberRef> interval =
    CFNumberCreate(0, kCFNumberIntType, &kSamplingInterval);
  if (!interval) {
    return false;
  }
  CFStringRef keys[1] = { CFSTR(DTPerformanceSession_Option_SamplingInterval) };
  CFNumberRef values[1] = { interval };
  AutoReleased<CFDictionaryRef> options =
    CFDictionaryCreate(kCFAllocatorDefault, (const void**)keys,
                       (const void**)values, 1, &kCFTypeDictionaryKeyCallBacks,
                       &kCFTypeDictionaryValueCallBacks);
  if (!options) {
    return false;
  }

  if (!DTPerformanceSessionAddInstrument(gSession,
                                         CFSTR(DTPerformanceSession_TimeProfiler),
                                         options, nullptr, &error)) {
    return Error(error);
  }

  return Resume();
}
Exemplo n.º 7
0
void BatchGUI::SetupConnect()
{
    connect( this->ui.addButton, SIGNAL(clicked()), this, SLOT(AddProcess()) );
    //
    connect( this->ui.beginButton, SIGNAL(clicked()), this, SLOT(BeginProcess()) );
    //
    connect( this->ui.appButton, SIGNAL(clicked()), this, SLOT(SelectFile()) );
    //
    connect( this->ui.cleanButton, SIGNAL(clicked()), this, SLOT(CleanAll()) );
    //
    connect( this->ui.stopButton, SIGNAL(clicked()), this, SLOT(StopAll()) );
    //
    connect( this->ui.resumeButton, SIGNAL(clicked()), this, SLOT(Resume()) );
    //
    connect( this->ui.resetButton, SIGNAL(clicked()), this, SLOT(ResetAll()) );
    return;
}
Exemplo n.º 8
0
HRESULT CWinThread::Create( IWinRunnable* piRunnable )
{
	assert(!m_h);
	assert(piRunnable);
	if (m_h)
		return AtlHresultFromWin32(ERROR_ALREADY_INITIALIZED);

	if (!piRunnable)
		return E_POINTER;

	// use _beginthreadex for initialization of c runtime lib
	m_h = (HANDLE)_beginthreadex(NULL, 0, RunThreadFunc, piRunnable, CREATE_SUSPENDED, NULL);
	if (!m_h)
		return GetLastError() ? AtlHresultFromLastError() : E_FAIL;

	Resume();
	return S_OK;
}
Exemplo n.º 9
0
void GameTable::TogglePause()
{
    if (isPaused)
    {
        isPaused = false;
        state = prevState;

        Resume();
    }
    else
    {
        isPaused = true;
        prevState = state;
        state = GameTableState::Paused;

        Pause();
    }
}
Exemplo n.º 10
0
LTBOOL CLoadingScreen::Show(LTBOOL bRun)
{
	if (bRun && !GetConsoleInt("DynamicLoadScreen",1))
		bRun = LTFALSE;
	// Make sure we're in the correct state
	if (m_eCurState == STATE_NONE)
	{
		if (!Init())
			return LTFALSE;
	}

	if (m_eCurState != STATE_INIT)
		return LTFALSE;

	// Turn off the cursor
	g_pCursorMgr->UseCursor(LTFALSE);
	
	// Set up the FarZ & turn off fog (farz of 0 is bogus)

	m_nOldFarZ = GetConsoleInt("FarZ", 10000);
	m_nOldFarZ = m_nOldFarZ == 0 ? 10000 : m_nOldFarZ;

	m_bOldFogEnable = (LTBOOL) GetConsoleInt("FogEnable", 0);

	g_pGameClientShell->SetFarZ(10000);
	WriteConsoleInt("FogEnable", 0);

	// Make sure we're not in optimized 2D mode (happens sometimes...)
	g_pLTClient->EndOptimized2D();

	
	// Go into the right state..
	m_eCurState = STATE_SHOW;

	// Update once so the screen's showing
	Update();

	// Start updating if they wanted it to..
	if (bRun)
		return Resume();

	// Ok, it's visible or active
	return LTTRUE;
}
Exemplo n.º 11
0
		bool MT_Thread::StartThread(){
	
			//如果已經启动则返回
			if(m_hHandle !=NULL){
				PauseThread(false);
				Resume();
				return true;	
			}
			//不暂停
			m_bPause	= false;
			//不退出循环调用
			m_bExit		= false;
			//开始线程
			m_hHandle = (HANDLE)_beginthreadex(NULL,0,MT_Thread::Run,(void*)this,0,&m_iThreadID);
			//如果线程创建失败
			if(m_hHandle==NULL)
				return false;
			return true;
		}
Exemplo n.º 12
0
	bool MonsterAI::BeginSkill(long skillId, long skillLvl, long x, long y, CMoveShape* target)
	{
		if (target == NULL)
		{
			LogError(AI_MODULE, "Target object is null.");
			return false;
		}

		LogDebug(AI_MODULE, "skillId=%d, skillLvl=%d, x=%d, y=%d, target=%s",
			skillId, skillLvl, x, y, target->GetExID().tostring());
		CMonster *monster = static_cast<CMonster*>(GetOwner());
		monster->InitSkillInstance(skillId, skillLvl, 0, 0, 0, NULL_GUID, 5);
		if(!BaseAI::BeginSkill(monster->GetInstanceSkill(), x, y, target))
		{
			Resume(OPER_FAILED_TIME);
			return false;
		}
		return true;
	}
Exemplo n.º 13
0
void PauseMenu::DoRestart()
{
	auto engine = STGEngine::GetInstance();
	auto scene = (GameScene*)Game::GetInstance()->GetScene().Get();
	scene->STGFadeOut(30);

	auto scheduler = scene->GetScheduler();
	Ptr<FrameTimer> timer = Ptr<FrameTimer>::New();
	timer->SetFrame(30);
	timer->run = [this, scene, engine]()
	{
		scene->Restart();
		Clear();
		Resume();
	};
	scheduler->AddFrameTimer(timer);

	EventSystem::GetInstance()->UnRegisterKeyDownListener(this);
}
Exemplo n.º 14
0
int LLBC_ThreadManager::ResumeAll()
{
    for (int i = 0; i < LLBC_CFG_THREAD_MAX_THREAD_NUM; i++)
    {
        LLBC_ThreadDescriptor *threadDesc = _threads[i];
        while (threadDesc)
        {
            LLBC_ThreadDescriptor *tmpThreadDesc = threadDesc;
            threadDesc = threadDesc->GetThreadNext();

            if (Resume(tmpThreadDesc->GetHandle()) != LLBC_OK)
            {
                return LLBC_FAILED;
            }
        }
    }

    return LLBC_OK;
}
    bool CCE3SoundWrapper::IsPlaying()
    {
        if ( IsActive() )
        {
            // Returns true if at least one sound is playing
            ISound* sound = GetPreferredSound();

            bool bPlaying = IsSoundPlaying( sound );

            if ( !bPlaying && !m_bPaused && !m_sSoundOrEvent.empty() )
            {
                Resume(); // restore consistency
            }

            return IsSoundPlaying( sound );
        }

        return false;
    }
Exemplo n.º 16
0
void CMyControl::Poll()
{
	super::Poll();

#if defined(HOLD_PIN) && defined(RESUME_PIN)

	if (IsHold())
	{
		if (_resume.IsOn())
		{
			Resume();
		}
	} 
	else if (_hold.IsOn())
	{
		Hold();
	}
#endif
}
Exemplo n.º 17
0
uint8_t PillMgr_t::Write(uint8_t MemAddr, void *Ptr, uint32_t Length) {
    uint8_t *p8 = (uint8_t*)Ptr;
    Resume();
    // Write page by page
    while(Length) {
        uint8_t ToWriteCnt = (Length > PILL_PAGE_SZ)? PILL_PAGE_SZ : Length;
        // Try to write
        uint32_t Retries = 0;
        while(true) {
//            Uart.Printf("Wr: try %u\r", Retries);
            if(i2c->WriteWrite(PILL_I2C_ADDR, &MemAddr, 1, p8, ToWriteCnt) == OK) {
                Length -= ToWriteCnt;
                p8 += ToWriteCnt;
                MemAddr += ToWriteCnt;
                break;  // get out of trying
            }
            else {
                Retries++;
                if(Retries > 4) {
                    Uart.Printf("Timeout1\r");
                    Standby();
                    return TIMEOUT;
                }
                chThdSleepMilliseconds(4);   // Allow memory to complete writing
            }
        } // while trying
    }
    // Wait completion
    uint32_t Retries = 0;
    do {
//        Uart.Printf("Wait: try %u\r", Retries);
        chThdSleepMilliseconds(1);
        Retries++;
        if(Retries > 5) {
//            Uart.Printf("Timeout2\r");
            Standby();
            return TIMEOUT;
        }
    } while(i2c->CheckAddress(PILL_I2C_ADDR) != OK);
    Standby();
    return OK;
}
Exemplo n.º 18
0
Error PhysicalMediaOutput::ChangePosition(int32 position)
{
   Error     error = kError_NoErr;
   bool      bWasPaused = m_bPause;

   if (m_pPmi->IsStreaming())
      return kError_FileSeekNotSupported;

   m_pMutex->Acquire();

   //Debug_v("Pause PMO");
   Pause();
   //Debug_v("Pause LMC");
   m_pLmc->Pause();
   //Debug_v("Pause PMI");
   m_pPmi->Pause();

   //Debug_v("Clear PMO");
   Clear();
   //Debug_v("Clear LMC");
   m_pLmc->Clear();
   //Debug_v("Clear PMI");
   m_pPmi->Clear();

   //Debug_v("Change pos");
   m_pLmc->ChangePosition(position);

   //Debug_v("Resume PMI");
   m_pPmi->Resume();
   //Debug_v("Resume LMC");
   m_pLmc->Resume();

   if (!bWasPaused)
   {
      //Debug_v("Resume PMO");
      Resume();
   }   

   m_pMutex->Release();

   return error;
}  
HRESULT CAVISplitter::Seek(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
{
	// We must stop the pushing thread before we change
	// the seek parameters -- especially for VBR seeking, 
	// where we might re-seek based on the incoming data.	
	CAutoLock lock(&m_csSeeking);

	if (tStop == 0 || tStop < tStart)
		tStop = GetDuration();

	bool bShouldRestart = Suspend();
	m_tStart = tStart;
	m_tStop = tStop;
	m_dRate = dRate;
	m_scanner.Seek(m_tStart);
	if (bShouldRestart)
		Resume();
	
	return S_OK;
}
Exemplo n.º 20
0
/**
  * @brief  This function handles EXTI14_15_IRQ Handler.
  * @param  None
  * @retval None
  */
void EXTI4_15_IRQHandler(void)
{
  
  if (EXTI_GetITStatus(TAMPER_BUTTON_EXTI_LINE) != RESET)
  {
    /* Check if the remote wakeup feature is enabled */
    if (USB_Device_dev.dev.DevRemoteWakeup)
    {
      /* Exit low power mode and re-configure clocks */
      Resume(RESUME_INTERNAL);
      USB_Device_dev.dev.device_status = USB_Device_dev.dev.device_old_status;
      remote_wakeup =1;
      /*Disable Remote wakeup Feature*/
      USB_Device_dev.dev.DevRemoteWakeup = 0;
    }
    
    /* Clear the EXTI line pending bit */
    EXTI_ClearITPendingBit(TAMPER_BUTTON_EXTI_LINE);
  }
}
Exemplo n.º 21
0
void PillMgr_t::Check() {
//    Uart.Printf("PillChk\r");
    Resume();
    if(IsConnectedNow) {    // Check if disconnected
        if(i2c->CheckAddress(PILL_I2C_ADDR) == OK) State = pillNoChange;
        else {
            IsConnectedNow = false;
            State = pillJustDisconnected;
        }
    }
    else {  // Was not connected
        uint8_t Rslt = Read(PILL_DATA_ADDR, &Pill, PILL_SZ);
        if(Rslt == OK) {
            IsConnectedNow = true;
            State = pillJustConnected;
        }
        else State = pillNoChange;
    }
    Standby();
}
Exemplo n.º 22
0
	bool MonsterAI::RandomRun()
	{
		CMonster *monster = static_cast<CMonster*>(GetOwner());
		if (monster == NULL)
		{
			LogError(AI_MODULE, "MosterAI has no owner object...");
		}
		assert(monster);
		if(random(10000) < monster->GetMoveRandomValue())
		{
			long dir = 0;
			long curX = monster->GetTileX();
			long curY = monster->GetTileY();
			long dis = monster->Distance(curX, curY, m_BornPos.x, m_BornPos.y);
			if(dis > monster->GetPeaceMoveRange())
			{
				dir = GetLineDir(curX, curY, m_BornPos.x, m_BornPos.y);
				long gdir = (8 - dir) % 8;
				if(gdir >= 2 || gdir <= 6)
				{
					dir = (dir + random(3) - 1 + 8) % 8;
				}
			}
			else
			{
				dir = random(8);
			}

			long maxRunTimes = monster->GetMaxRunTimes();
			long minRunTimes = monster->GetMinRunTimes();

			AI_EVENT_SENDER(this).MoveByStep(dir, random(maxRunTimes - minRunTimes) + minRunTimes);
			// drive the ai
			Resume(0);
		}
		else
		{
			Stand(monster->GetStopFrame());
		}
		return true;
	}
Exemplo n.º 23
0
void CPUThread::Run()
{
	if(IsRunning()) Stop();
	if(IsPaused())
	{
		Resume();
		return;
	}
	
	wxGetApp().SendDbgCommand(DID_START_THREAD, this);

	m_status = Running;

	SetPc(entry);
	InitStack();
	InitRegs();
	DoRun();
	Emu.CheckStatus();

	wxGetApp().SendDbgCommand(DID_STARTED_THREAD, this);
}
Exemplo n.º 24
0
bool TWtDev::Init(quint8 nPort, int bps)
{
    if (!m_bLoadflag)
    {
        LogMsg("lane",tr("[TWtDev.Connect]加载DLL失败"));
        return false;
    }
    QString p=QObject::tr("Com%1").arg(nPort);
    int ret=Dev_SetCom(p.toLocal8Bit().data(), bps);;

    if (ret==0)
    {
        Resume();
        return true;
    }
    else
    {
        LogMsg("lane",tr("[TWtDev.OpenDev]WimDev_SetCom失败"));
        return false;
    }
}
Exemplo n.º 25
0
//============================================================
// <T>响应服务器操作命令。</T>
//
// @param command 服务器的操作命令
// @return 处理结果
//============================================================
TResult FServer::DoCommand(EServerCommand command){
   MO_INFO("Server '%s' command event. (command=%d).", (TCharC*)_name, command);
   TBool result = OnCommand(command);
   // 处理命令
   if(result){
      switch(command){
         case EServerCommand_Reload:
            Reload();
            break;
         case EServerCommand_Suspend:
            Suspend();
            break;
         case EServerCommand_Resume:
            Resume();
            break;
         default:
            break;
      }
   }
   return ESuccess;
}
bool KinectSpeechRecognizer::LoadGrammar(std::string fileName)
{
    if(speechGrammar)
    {
        speechGrammar->Release();
        speechGrammar = NULL;
    }

    HRESULT hr = speechContext->CreateGrammar(1, &speechGrammar);

    if (SUCCEEDED(hr))
    {
        Pause();

        std::wstring wideFileName = std::wstring(fileName.begin(), fileName.end());

        // Populate recognition grammar from file
        hr = speechGrammar->LoadCmdFromFile(wideFileName.c_str(), SPLO_STATIC);
        if (SUCCEEDED(hr))
        {
            // Specify that all top level rules in grammar are now active
            hr = speechGrammar->SetRuleState(NULL, NULL, SPRS_ACTIVE);
        }

        Resume();
    }

    if(SUCCEEDED(hr))
        return true;
    else
    {
        //If failed, release the current grammar if it has anything
        if(speechGrammar)
        {
            speechGrammar->Release();
            speechGrammar = NULL;
        }
        return false;
    }
}
Exemplo n.º 27
0
int LLBC_ThreadManager::ResumeTask(LLBC_BaseTask *task)
{
    if (UNLIKELY(!task))
    {
        LLBC_SetLastError(LLBC_ERROR_ARG);
        return LLBC_FAILED;
    }

    LLBC_Guard guard(_lock);

    std::vector<LLBC_Handle> willResumeThreads;
    for (int i = 0; i < LLBC_CFG_THREAD_MAX_THREAD_NUM; i++)
    {
        if (!_threads[i])
        {
            continue;
        }

        LLBC_ThreadDescriptor *threadDesc = _threads[i];
        while (threadDesc)
        {
            if (threadDesc->GetTask() == task)
            {
                willResumeThreads.push_back(threadDesc->GetHandle());
            }

            threadDesc = threadDesc->GetThreadNext();
        }
    }

    for (size_t i = 0; i < willResumeThreads.size(); i++)
    {
        if (Resume(willResumeThreads[i]) != LLBC_OK)
        {
            return LLBC_FAILED;
        }
    }

    return LLBC_OK;
}
Exemplo n.º 28
0
void
MachThread::ThreadWillResume(const DNBThreadResumeAction *thread_action)
{
    if (thread_action->addr != INVALID_NUB_ADDRESS)
        SetPC (thread_action->addr);

    SetState (thread_action->state);
    switch (thread_action->state)
    {
    case eStateStopped:
    case eStateSuspended:
        Suspend();
        break;

    case eStateRunning:
    case eStateStepping:
        Resume();
        break;
    }
    m_arch_ap->ThreadWillResume();
    m_stop_exception.Clear();
}
Exemplo n.º 29
0
wxThreadError wxThread::Kill()
{
    wxCHECK_MSG( This() != this, wxTHREAD_MISC_ERROR,
                 wxT("a thread can't kill itself") );

    switch ( m_internal->GetState() )
    {
        case STATE_NEW:
        case STATE_EXITED:
            return wxTHREAD_NOT_RUNNING;

        case STATE_PAUSED:
            // resume the thread first
            Resume();

            // fall through

        default:
            OSStatus err = MPTerminateTask( m_internal->GetId() , -1 ) ;
            if (err != noErr)
            {
                wxLogError( wxT("Failed to terminate a thread.") );

                return wxTHREAD_MISC_ERROR;
            }

            if ( m_isDetached )
            {
                delete this ;
            }
            else
            {
                // this should be retrieved by Wait actually
                m_internal->SetExitCode( (void*)-1 );
            }

            return wxTHREAD_NO_ERROR;
    }
}
Exemplo n.º 30
0
void i2c_t::Init(I2C_TypeDef *pi2c, uint32_t BitrateHz) {
    ii2c = pi2c;
    IBitrateHz = BitrateHz;
    if(ii2c == I2C1) {
        IPGpio = GPIOB;
        ISclPin = 6;
        ISdaPin = 7;
        PDmaTx = STM32_DMA1_STREAM6;
        PDmaRx = STM32_DMA1_STREAM7;
    }
    Standby();
    Resume();

    // ==== DMA ====
    // Here only unchanged parameters of the DMA are configured.
    // Setup Dma TX
    dmaStreamAllocate(PDmaTx, IRQ_PRIO_MEDIUM, i2cDmaIrqHandler, this);
    dmaStreamSetPeripheral(PDmaTx, &ii2c->DR);
    dmaStreamSetMode      (PDmaTx,
            DMA_PRIORITY_LOW |
            STM32_DMA_CR_MSIZE_BYTE |
            STM32_DMA_CR_PSIZE_BYTE |
            STM32_DMA_CR_MINC |         // Memory pointer increase
            STM32_DMA_CR_DIR_M2P |      // Direction is memory to peripheral
            STM32_DMA_CR_TCIE           // Enable Transmission Complete IRQ
             );

    // Setup Dma RX
    dmaStreamAllocate(PDmaRx, IRQ_PRIO_MEDIUM, i2cDmaIrqHandler, this);
    dmaStreamSetPeripheral(PDmaRx, &ii2c->DR);
    dmaStreamSetMode      (PDmaRx,
            DMA_PRIORITY_LOW |
            STM32_DMA_CR_MSIZE_BYTE |
            STM32_DMA_CR_PSIZE_BYTE |
            STM32_DMA_CR_MINC |         // Memory pointer increase
            STM32_DMA_CR_DIR_P2M        // Direction is peripheral to memory
            | STM32_DMA_CR_TCIE         // Enable Transmission Complete IRQ
             );
}