• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ IsMainThread函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了IsMainThread函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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,代码来源:MainThreadRunner.c


示例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,代码来源:Win32Wnd.cpp


示例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,代码来源:Win32Wnd.cpp


示例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,代码来源:AlphaMask.cpp


示例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,代码来源:GtkEvent.cpp


示例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,代码来源:Window.cpp


示例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,代码来源:CProxyDirect3D9.cpp


示例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,代码来源:SchedulerBase.cpp


示例9: ASSERT

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


示例10: DestroyShader

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


示例11: DestroyProgram

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


示例12: DestroyVbo

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


示例13: DestroyTexture

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


示例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,代码来源:Event.cpp


示例15: DestroyRenderbuffer

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


示例16: ASSERT

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


示例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,代码来源:OpenGLContext.cpp


示例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,代码来源:MainThreadRunner.c


示例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,代码来源:Win32Wnd.cpp


示例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,代码来源:GtkCapture.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ IsMember函数代码示例发布时间:2022-05-30
下一篇:
C++ IsLookonMode函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap