本文整理汇总了C++中IThread::changeState方法的典型用法代码示例。如果您正苦于以下问题:C++ IThread::changeState方法的具体用法?C++ IThread::changeState怎么用?C++ IThread::changeState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IThread
的用法示例。
在下文中一共展示了IThread::changeState方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
//--------------------------------------------------------------------
void IThread::run(void* _mythread)
{
// try to cast the given parameter to IThread pointer
IThread* mythread = static_cast<IThread*>(_mythread);
if (mythread == NULL)
{
NR_Log(Log::LOG_KERNEL, Log::LL_ERROR, "IThread: not valid parameter was specified for IThread::run(void*) method");
return;
}
// now loop the thread until some messages occurs
bool run = true;
while (run){
// kernel requested to suspend the thread
if (mythread->mThreadState == THREAD_NEXT_SUSPEND)
{
// notice about suspending and go into sleep mode
mythread->changeState(THREAD_SLEEPING);
mythread->_noticeSuspend();
// kernel requested to resume the execution
}else if (mythread->mThreadState == THREAD_NEXT_RESUME)
{
// notice about resuming the work and start it again
mythread->changeState(THREAD_RUNNING);
mythread->_noticeResume();
// kernel does not requested anything, so run the task
}else if (mythread->mThreadState == THREAD_RUNNING)
{
mythread->_noticeUpdate();
}
// check for the stop message, then stop the thread
// this is a reading mutex, so do not have to lock it
run = mythread->mThreadState != THREAD_STOP;
// we now yield the used timeslice for another threads
yield(mythread);
}
// notice to stop the underlying task
mythread->_noticeStop();
// exit the thread
//return NULL;
}