您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ IsMainThread函数代码示例

51自学网 2021-06-01 21:41:48
  C++
这篇教程C++ IsMainThread函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中IsMainThread函数的典型用法代码示例。如果您正苦于以下问题:C++ IsMainThread函数的具体用法?C++ IsMainThread怎么用?C++ IsMainThread使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了IsMainThread函数的23个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: RunJob

int32_t RunJob(MainThreadRunner *runner, MainThreadJob *job){  JobEntry entry;  // initialize the entry  entry.runner = runner;  entry.pepper_instance = runner->pepper_instance_;  entry.job = job;  bool in_main_thread = IsMainThread();  // Must be off main thread, or on a pseudothread.  assert(!in_main_thread || in_pseudo_thread_);  // Thread type specific initialization.  if (in_main_thread) {    entry.pseudo_thread_job = true;  } else {    entry.pseudo_thread_job = false;    // Init condition variable.    entry.is_done = false;    int ret = pthread_mutex_init(&entry.done_mutex, NULL);    assert(!ret);    ret = pthread_cond_init(&entry.done_cond, NULL);    assert(!ret);  }  // put the job on the queue  pthread_mutex_lock(&(runner->lock_));  //job_queue_.push_back(&entry);  //JobEntry_list_push_back(&entry, &(runner->job_queue_));  runner->job_queue_[runner->qtail]=&entry;  runner->qtail = (runner->qtail+1)%QSIZE;  runner->size++;  pthread_mutex_unlock(&(runner->lock_));#ifdef USE_PEPPER  // Schedule the job.  //pp::Module::Get()->core()->CallOnMainThread(0,  //    pp::CompletionCallback(&DoWorkShim, this), PP_OK);  g_core_interface->CallOnMainThread(0,      PP_MakeCompletionCallback(&DoWorkShim, runner), PP_OK);#endif  // Block differntly on the main thread.  if (entry.pseudo_thread_job) {    // block pseudothread until job is done    PseudoThreadBlock();  } else {    // wait on condition until the job is done    pthread_mutex_lock(&entry.done_mutex);    while (!entry.is_done) {      pthread_cond_wait(&entry.done_cond, &entry.done_mutex);    }    pthread_mutex_unlock(&entry.done_mutex);    pthread_mutex_destroy(&entry.done_mutex);    pthread_cond_destroy(&entry.done_cond);  }  // Cleanup.  //delete job;  free(job);  return entry.result;}
开发者ID:bxl1989,项目名称:SDL_nacl_c,代码行数:60,


示例2: ASSERT_

void Ctrl::EventLoop(Ctrl *ctrl){	GuiLock __;	ASSERT_(IsMainThread(), "EventLoop can only run in the main thread");	ASSERT(LoopLevel == 0 || ctrl);	LoopLevel++;	LLOG("Entering event loop at level " << LoopLevel << LOG_BEGIN);	Ptr<Ctrl> ploop;	if(ctrl) {		ploop = LoopCtrl;		LoopCtrl = ctrl;		ctrl->inloop = true;	}	bool quit = false;	int64 loopno = ++EventLoopNo;	ProcessEvents(&quit);	while(loopno > EndSessionLoopNo && !quit && (ctrl ? ctrl->IsOpen() && ctrl->InLoop() : GetTopCtrls().GetCount()))	{//		LLOG(GetSysTime() << " % " << (unsigned)msecs() % 10000 << ": EventLoop / GuiSleep");		SyncCaret();		GuiSleep(1000);//		LLOG(GetSysTime() << " % " << (unsigned)msecs() % 10000 << ": EventLoop / ProcessEvents");		ProcessEvents(&quit);//		LLOG(GetSysTime() << " % " << (unsigned)msecs() % 10000 << ": EventLoop / after ProcessEvents");	}	if(ctrl)		LoopCtrl = ploop;	LoopLevel--;	LLOG(LOG_END << "Leaving event loop ");}
开发者ID:koz4k,项目名称:soccer,代码行数:32,


示例3: ASSERT

void Ctrl::GuiSleep0(int ms){	GuiLock __;	ASSERT(IsMainThread());	ELOG("GuiSleep");	if(EndSession())		return;	ELOG("GuiSleep 2");	int level = LeaveGuiMutexAll();#if !defined(flagDLL) && !defined(PLATFORM_WINCE)	if(!OverwatchThread) {		DWORD dummy;		OverwatchThread = CreateThread(NULL, 0x100000, Win32OverwatchThread, NULL, 0, &dummy);		ELOG("ExitLoopEventWait 1");		ExitLoopEvent().Wait();	}	HANDLE h[1];	*h = ExitLoopEvent().GetHandle();	ELOG("ExitLoopEventWait 2 " << (void *)*h);	MsgWaitForMultipleObjects(1, h, FALSE, ms, QS_ALLINPUT);#else	MsgWaitForMultipleObjects(0, NULL, FALSE, ms, QS_ALLINPUT);#endif	EnterGuiMutex(level);}
开发者ID:dreamsxin,项目名称:ultimatepp,代码行数:25,


示例4:

SpanRect::SpanRect(const Rect &inRect, int inAA){   mAA =  inAA;   mAAMask = ~(mAA-1);   mRect = inRect * inAA;   mWinding = 0xffffffff;   mTransitions = 0;      if (IsMainThread())   {      if (sTransitionsBuffer.size() < mRect.h)         sTransitionsBuffer.resize(mRect.h);      mTransitions = &sTransitionsBuffer[0];   }   else   {      mTransitions = new Transitions[mRect.h];   }      for (int y = 0; y < mRect.h; y++)   {      mTransitions[y].mLeft = 0;      mTransitions[y].mX.resize(0);   }      mMinX = (mRect.x - 1) << 10;   mMaxX = (mRect.x1()) << 10;   mLeftPos = mRect.x;}
开发者ID:AZidan,项目名称:nme,代码行数:29,


示例5: ASSERT_

void Ctrl::EventLoop(Ctrl *ctrl){	GuiLock __;	ASSERT_(IsMainThread(), "EventLoop can only run in the main thread");	ASSERT(LoopLevel == 0 || ctrl);	LoopLevel++;	LLOG("Entering event loop at level " << LoopLevel << LOG_BEGIN);	if(!GetMouseRight() && !GetMouseMiddle() && !GetMouseLeft())		ReleaseCtrlCapture();	Ptr<Ctrl> ploop;	if(ctrl) {		ploop = LoopCtrl;		LoopCtrl = ctrl;		ctrl->inloop = true;	}	while(!IsEndSession() &&	      (ctrl ? ctrl->IsOpen() && ctrl->InLoop() : GetTopCtrls().GetCount())) {		FetchEvents(TRUE);		ProcessEvents();	}	if(ctrl)		LoopCtrl = ploop;	LoopLevel--;	LLOG(LOG_END << "Leaving event loop ");}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:27,


示例6: DuiLogInfo

	bool CWin::RegisterSkin(STRINGorID xml, LPCTSTR type /* = NULL */, IDialogBuilderCallback* pCallback /* = NULL */, CControlUI* pParent /* = NULL */)	{		DuiLogInfo(_T("RegisterSkin xml:%s,type:%s"), (LPCTSTR)xml.m_lpstr, type == NULL ? _T("0") : type);		assert(IsWindow());		assert(IsMainThread());		UnRegisterSkin();		_paintManager = new CPaintManagerUI();		_paintManager->Init(m_hWnd);				CControlUI* pRoot = this->CreateRoot(xml,type,pCallback,pParent);		if (!pRoot)			DuiLogError(_T("RegisterSkin xml:%s,type:%s"), (LPCTSTR)xml.m_lpstr, (type == NULL ? _T("0") : type));		CDuiString sError = CDuiString::FormatString(_T("Failed to parse XML:%s"), (LPCTSTR)xml.m_lpstr);		char serror[MAX_PATH] = { 0 };		sprintf_s(serror, MAX_PATH, "Failed to parse XML:%s", (LPCTSTR)xml.m_lpstr);		ASSERT(pRoot && "Failed to parse XML");		DuiAssertX(pRoot, serror);		if (pRoot)		{			_bValid = TRUE;			return _paintManager->AttachDialog(pRoot);		}		return false;	}
开发者ID:uvbs,项目名称:myduilib,代码行数:26,


示例7: CreateDeviceSecondCallCheck

//////////////////////////////////////////////////// CreateDeviceSecondCallCheck//// Check for, and handle subsequent calls to create device// Know to occur with RTSSHooks.dll (EVGA Precision X on screen display)//////////////////////////////////////////////////bool CreateDeviceSecondCallCheck(HRESULT& hOutResult, IDirect3D9* pDirect3D, UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags,                                 D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DDevice9** ppReturnedDeviceInterface){    static uint uiCreateCount = 0;    // Also check for invalid size    if (pPresentationParameters->BackBufferWidth == 0)    {        WriteDebugEvent(SString(" Passing through call #%d to CreateDevice because size is invalid", uiCreateCount));        return true;    }    // Also check for calls from other threads    if (!IsMainThread())    {        SString strMessage(" Passing through call #%d to CreateDevice because not main thread", uiCreateCount);        WriteDebugEvent(strMessage);        AddReportLog(8627, strMessage);        return true;    }    if (++uiCreateCount == 1)        return false;    WriteDebugEvent(SString(" Passing through call #%d to CreateDevice", uiCreateCount));    hOutResult = pDirect3D->CreateDevice(Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, ppReturnedDeviceInterface);    return true;}
开发者ID:ccw808,项目名称:mtasa-blue,代码行数:35,


示例8: LogAssert

  bool SchedulerBase::CreateSignalChannel(int *outSigId, SignalCallback callback, void *userdata)  {    LogAssert(IsMainThread());    if (!LogVerify(outSigId) || !LogVerify(callback))      return false;    *outSigId = -1;    // Create a set of pipes    int fdPipe[2];    int flags;    int ret = pipe(fdPipe);    if (ret != 0)    {      gLog.ErrnoError(errno, "Unable to create pipe for signaling");      return false;    }    FileDescriptor pipeRead(fdPipe[0]);    FileDescriptor pipeWrite(fdPipe[1]);    flags = fcntl(pipeRead, F_GETFL);    flags = flags | O_NONBLOCK;    if (-1 == fcntl(pipeRead, F_SETFL, flags))    {      gLog.LogError("Failed to set read pipe to non-blocking.");      return false;    }    flags = fcntl(pipeWrite, F_GETFL);    flags = flags | O_NONBLOCK;    if (-1 == fcntl(pipeWrite, F_SETFL, flags))    {      gLog.LogError("Failed to set write pipe to non-blocking.");      return false;    }    if (!watchSocket(pipeRead))      return false;    schedulerSignalItem item;    item.callback = callback;    item.userdata = userdata;    item.fdWrite = pipeWrite;    item.fdRead = pipeRead;    m_signals[item.fdRead] = item;    pipeWrite.Detach();    pipeRead.Detach();    *outSigId = item.fdWrite;    gLog.Optional(Log::TimerDetail, "Created signal channel from %d to %d .", item.fdWrite, item.fdRead);    return true;  }
开发者ID:Lennie,项目名称:OpenBFDD,代码行数:59,


示例9: ASSERT

void Ctrl::GuiSleep0(int ms){	GuiLock __;	ASSERT(IsMainThread());	LLOG("GuiSleep");	int level = LeaveGuiMutexAll();	FBSleep(ms);	EnterGuiMutex(level);}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:9,


示例10: DestroyShader

 void DestroyShader(unsigned int inShader) {    if ( !IsMainThread() )    {       mHasZombie = true;       mZombieShaders.push_back(inShader);    }    else       glDeleteShader(inShader); }
开发者ID:OswaldoD,项目名称:TrigonometricPark,代码行数:10,


示例11: DestroyProgram

 void DestroyProgram(unsigned int inProg) {    if ( !IsMainThread() )    {       mHasZombie = true;       mZombiePrograms.push_back(inProg);    }    else       glDeleteProgram(inProg); }
开发者ID:OswaldoD,项目名称:TrigonometricPark,代码行数:10,


示例12: DestroyVbo

 void DestroyVbo(unsigned int inVbo) {    if ( !IsMainThread() )    {       mHasZombie = true;       mZombieVbos.push_back(inVbo);    }    else       glDeleteBuffers(1,&inVbo); }
开发者ID:OswaldoD,项目名称:TrigonometricPark,代码行数:10,


示例13: DestroyTexture

 void DestroyTexture(unsigned int inTex) {    if ( !IsMainThread() )    {       mHasZombie = true;       mZombieTextures.push_back(inTex);    }    else       glDeleteTextures(1,&inTex); }
开发者ID:Greg209,项目名称:NME,代码行数:10,


示例14: ASSERT

void Ctrl::GuiSleep(int ms){	GuiLock __;	ASSERT(IsMainThread());//	LLOG("GuiSleep");	int level = LeaveGuiMutexAll();	socket.Timeout(ms).WaitRead();	socket.Timeout(20000);	EnterGuiMutex(level);}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:10,


示例15: DestroyRenderbuffer

 void DestroyRenderbuffer(unsigned int inBuffer) {    if ( !IsMainThread() )    {       mHasZombie = true;       mZombieRenderbuffers.push_back(inBuffer);    }    else       glDeleteRenderbuffers(1,&inBuffer); }
开发者ID:OswaldoD,项目名称:TrigonometricPark,代码行数:10,


示例16: ASSERT

bool Ctrl::SetWndCapture(){	GuiLock __;	ASSERT(IsMainThread());	HWND hwnd = GetHWND();	if(hwnd) {		::SetCapture(hwnd);		return true;	}	return false;}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:11,


示例17: DestroyNativeTexture

   void DestroyNativeTexture(void *inNativeTexture)   {      GLuint tid = (GLuint)(size_t)inNativeTexture;      if ( !IsMainThread() )      {         //printf("Warning - leaking texture %d", tid );		 mZombieTextures.push_back(tid);      }      else         glDeleteTextures(1,&tid);   }
开发者ID:DjPale,项目名称:NME,代码行数:11,


示例18: PseudoThreadResume

void PseudoThreadResume(){  // Must be run from the main thread.  assert(IsMainThread());  // Pseudothread must have been forked.  assert(forked_pseudo_thread_);  // Can only be run from the main thread.  assert(!in_pseudo_thread_);  if (!setjmp(main_thread_state_)) {    // Go back to the pseudo thread after saving state.    longjmp(pseudo_thread_state_, 1);  }  in_pseudo_thread_ = false;}
开发者ID:bxl1989,项目名称:SDL_nacl_c,代码行数:13,


示例19: LLOG

bool Ctrl::SetWndCapture(){	GuiLock __;	LLOG("Ctrl::SetWndCapture() in " << UPP::Name(this));	ASSERT(IsMainThread());	HWND hwnd = GetHWND();	if(hwnd) {		::SetCapture(hwnd);		LLOG("SetCapture succeeded");		return true;	}	return false;}
开发者ID:koz4k,项目名称:soccer,代码行数:13,


示例20: ASSERT

bool Ctrl::ReleaseWndCapture0(){	GuiLock __;	ASSERT(IsMainThread());	LLOG("ReleaseWndCapture");	if(grabwindow) {		gdk_pointer_ungrab(CurrentTime);		grabwindow = NULL;		StartGrabPopup();		return true;	}	return false;}
开发者ID:dreamsxin,项目名称:ultimatepp,代码行数:13,


示例21: PseudoThreadHeadroomFork

void PseudoThreadHeadroomFork(	  int bytes_headroom, void *(*func)(void *arg), void *arg){  // Must be run from the main thread.  assert(IsMainThread());  // Only one pseudothread can be forked.  assert(!forked_pseudo_thread_);  // Leave a gap of bytes_headroom on the stack between  alloca(bytes_headroom);  // Goto pseudothread, but remeber how to come back here.  if (!setjmp(main_thread_state_)) {    InnerPseudoThreadFork(func, arg);  }  in_pseudo_thread_ = false;}
开发者ID:bxl1989,项目名称:SDL_nacl_c,代码行数:14,


示例22: assert

void CInfoWindow::ShowInfo(HWND hparent,	POINT pt,	LPCTSTR pszText){	assert(IsMainThread());	this->KillTimer(_nTimerId);	ShowWindow(SW_HIDE);	SetText(pszText);//	SetParent(hparent);	AdjustWindow(hparent,pt);	ShowWindow(SW_SHOWNORMAL);	this->SetTimer(_nTimerId,1500);}
开发者ID:yuechuanbingzhi163,项目名称:myduilib,代码行数:14,


示例23: LLOG

bool Ctrl::ProcessEvent(bool *quit){	LLOG("@ ProcessEvent");	ASSERT(IsMainThread());	if(!GetMouseLeft() && !GetMouseRight() && !GetMouseMiddle())		ReleaseCtrlCapture();	if(FBProcessEvent(quit)) {		LLOG("FBProcesEvent returned true");		SyncTopWindows();		DefferedFocusSync();		SyncCaret();		return true;	}	return false;}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:15,



注:本文中的IsMainThread函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ IsMember函数代码示例
C++ IsLookonMode函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。