當前位置: 首頁>>代碼示例>>C++>>正文


C++ GetThreadPriority函數代碼示例

本文整理匯總了C++中GetThreadPriority函數的典型用法代碼示例。如果您正苦於以下問題:C++ GetThreadPriority函數的具體用法?C++ GetThreadPriority怎麽用?C++ GetThreadPriority使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了GetThreadPriority函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: JReference

JThread::JThread(int handle) 

  : JReference(handle) {

  priority = fromPlatform(

    GetThreadPriority((HANDLE)handle));

  ptarget = null;

}
開發者ID:neattools,項目名稱:neattools,代碼行數:11,代碼來源:JThread.cpp

示例2: GetThreadPriority

int CThread::GetPriority() const
{
#ifdef _WIN32
	return GetThreadPriority(m_hThread);
#elif _LINUX
	struct sched_param thread_param;
	int policy;
	pthread_getschedparam( m_threadId, &policy, &thread_param );
	return thread_param.sched_priority;
#endif
}
開發者ID:FWGS,項目名稱:libvinterface,代碼行數:11,代碼來源:threadtools.cpp

示例3: main_setRenderThreadPriority

void main_setRenderThreadPriority()
{
  int prios[]={
    GetThreadPriority(GetCurrentThread()),
    THREAD_PRIORITY_IDLE,
    THREAD_PRIORITY_LOWEST,
    THREAD_PRIORITY_NORMAL,
    THREAD_PRIORITY_HIGHEST,
  };
	SetThreadPriority(g_hThread,prios[cfg_render_prio]);
}
開發者ID:majek,項目名稱:avs,代碼行數:11,代碼來源:main.cpp

示例4: MPOS_Start

static void MPOS_Start(void) {
    #if defined(RB_MSVC_WIN32)
	    hApp = GetCurrentProcess();
        hThread = GetCurrentThread();

        iPriorityClass = GetPriorityClass(hApp);
        iPriority = GetThreadPriority(hThread);

        if (iPriorityClass != 0) SetPriorityClass(hApp, REALTIME_PRIORITY_CLASS);
        if (iPriority != THREAD_PRIORITY_ERROR_RETURN) SetThreadPriority(hThread, THREAD_PRIORITY_TIME_CRITICAL);
	#elif defined(RB_MSVC_WINCE)
        hThread = GetCurrentThread();
        iPriority = GetThreadPriority(hThread);
        if (iPriority != THREAD_PRIORITY_ERROR_RETURN) SetThreadPriority(hThread, THREAD_PRIORITY_TIME_CRITICAL);
    #elif defined(RB_LINUX)
	    iPriority = getpriority(PRIO_PROCESS, 0); //lazy to check error:p
        setpriority(PRIO_PROCESS, 0, -20);
    #else
        //backup & disable all IRQ except COM port's IRQ
    #endif
}
開發者ID:mhk2010,項目名稱:roboard-hexapod,代碼行數:21,代碼來源:com.cpp

示例5: sys_arch_timeouts

/*----------------------------------------------------------------------*/
struct sys_timeouts * sys_arch_timeouts(void)
{
  u8_t prio = GetThreadPriority(GetCurrentThread());
  u8_t offset = prio - LWIP_START_PRIO;
  if (prio == THREAD_PRIORITY_ERROR_RETURN) 
  {
    fprintf(stderr, "CreateThread failed with %d.\n", GetLastError()); 
    return &lwip_timeouts[LWIP_TASK_MAX];
  }
  if (offset >= 0 && offset < LWIP_TASK_MAX)
    return &lwip_timeouts[offset];
  return &lwip_timeouts[LWIP_TASK_MAX];
}
開發者ID:MetaEngine,項目名稱:lwip-win32,代碼行數:14,代碼來源:sys_arch.c

示例6: GetThreadPriority

UInt32	CAPThread::GetScheduledPriority()
{
#if TARGET_OS_MAC
    return CAPThread::getScheduledPriority( mPThread, CAPTHREAD_SCHEDULED_PRIORITY );
#elif TARGET_OS_WIN32
	UInt32 theAnswer = 0;
	if(mThreadHandle != NULL)
	{
		theAnswer = GetThreadPriority(mThreadHandle);
	}
	return theAnswer;
#endif
}
開發者ID:cchaz003,項目名稱:rivenx,代碼行數:13,代碼來源:CAPThread.cpp

示例7: GetThreadPriority

/** 等待給出的線程結束.
*/
void mvg::synch::joinThread(const TThreadHandle &threadHandle)
{
	if (threadHandle.isClear()) return;

	int prio = GetThreadPriority((HANDLE)threadHandle.hThread);
	if (THREAD_PRIORITY_ERROR_RETURN == prio)
		return; // 這邊表示這個不是一個正在運行的線程

	DWORD ret = WaitForSingleObject((HANDLE)threadHandle.hThread, INFINITE);
	if (ret != WAIT_OBJECT_0)
		std::cerr << "[mvg::synch::joinThread] Error waiting for thread completion!" << std::endl;

}
開發者ID:yueying,項目名稱:3DReconstruction,代碼行數:15,代碼來源:threads.cpp

示例8: pthread_self

pthread_t
pthread_self (void)
{
  pthread_t self;
  pthread_t nil = {NULL, 0};
  ptw32_thread_t * sp;

#if defined(_UWIN)
  if (!ptw32_selfThreadKey)
    return nil;
#endif

  sp = (ptw32_thread_t *) pthread_getspecific (ptw32_selfThreadKey);

  if (sp != NULL)
    {
      self = sp->ptHandle;
    }
  else
    {
      self = ptw32_new ();
      sp = (ptw32_thread_t *) self.p;

      if (sp != NULL)
	{
	  sp->implicit = 1;
	  sp->detachState = PTHREAD_CREATE_DETACHED;
	  sp->thread = GetCurrentThreadId ();

#if defined(NEED_DUPLICATEHANDLE)
	  sp->threadH = GetCurrentThread ();
#else
	  if (!DuplicateHandle (GetCurrentProcess (),
				GetCurrentThread (),
				GetCurrentProcess (),
				&sp->threadH,
				0, FALSE, DUPLICATE_SAME_ACCESS))
	    {
	      ptw32_threadReusePush (self);
	      return nil;
	    }
#endif

	  sp->sched_priority = GetThreadPriority (sp->threadH);
	  pthread_setspecific (ptw32_selfThreadKey, (void *) sp);
	}
    }

  return (self);

}				
開發者ID:qtekfun,項目名稱:htcDesire820Kernel,代碼行數:51,代碼來源:pthread_self.c

示例9: SDL_WM_SetCaption

void CUI_LoadMsg::enter(void) {
    need_refresh = 1;
    load_finished = 0;
//    setWindowTitle("zt - loading file...");
    SDL_WM_SetCaption("zt - [loading file]","zt - [loading file]");
    OldPriority = GetThreadPriority(GetCurrentThread());
    strtimer = strselect = 0;
    strtimer = SetTimer(NULL,strtimer,500,(TIMERPROC)TP_Load_Inc_Str);
    SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_BELOW_NORMAL);
    hThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)load_thread,NULL,0,&iID); 
    while(load_lock) {
        SDL_Delay(1);
    }
}
開發者ID:cmicali,項目名稱:ztracker,代碼行數:14,代碼來源:CUI_LoadMsg.cpp

示例10: lock

bool CThread::WaitForThreadExit(unsigned int milliseconds)
{
  bool bReturn = true;

  CSingleLock lock(m_CriticalSection);
  if (m_ThreadId && m_ThreadOpaque.handle != NULL)
  {
    // boost priority of thread we are waiting on to same as caller
    int callee = GetThreadPriority(m_ThreadOpaque.handle);
    int caller = GetThreadPriority(::GetCurrentThread());
    if(caller != THREAD_PRIORITY_ERROR_RETURN && caller > callee)
      SetThreadPriority(m_ThreadOpaque.handle, caller);

    lock.Leave();
    bReturn = m_TermEvent.WaitMSec(milliseconds);
    lock.Enter();

    // restore thread priority if thread hasn't exited
    if(callee != THREAD_PRIORITY_ERROR_RETURN && caller > callee && m_ThreadOpaque.handle)
      SetThreadPriority(m_ThreadOpaque.handle, callee);
  }
  return bReturn;
}
開發者ID:AchimTuran,項目名稱:xbmc,代碼行數:23,代碼來源:ThreadImpl.cpp

示例11: EvalPriorityExpand

void EvalPriorityExpand(const void *data, qCtx *ctx, qStr *out, qArgAry *args) 
{
	if (ctx->GetSafeMode()) {ctx->Throw(out, 301, "function not available"); return;}
	int priority = THREAD_PRIORITY_ERROR_RETURN;

	CStr pname = (*args)[0];

	if (!stricmp(pname,"low")) {
		priority = THREAD_PRIORITY_BELOW_NORMAL;
	}
	if (!stricmp(pname,"high")) {
		priority = THREAD_PRIORITY_ABOVE_NORMAL;

	}
	if (!stricmp(pname,"normal")) {
		priority = THREAD_PRIORITY_NORMAL;
	}
	if (!stricmp(pname,"lowest")) {
		priority = THREAD_PRIORITY_LOWEST;

	}
	if (!stricmp(pname,"highest")) {
		priority = THREAD_PRIORITY_HIGHEST;
	}

	if (priority == THREAD_PRIORITY_ERROR_RETURN)
		ctx->Throw(out, 353, "Priority must be one of low, high, normal, lowest, highest");
	else {

		DWORD was = GetThreadPriority(GetCurrentThread());

		SetThreadPriority(GetCurrentThread(), priority);

		try {
			ctx->Parse(args->GetAt(1),out);
		} catch (qCtxExAbort ex) {
			SetThreadPriority(GetCurrentThread(), was);
			throw ex;
		} catch (qCtxEx ex) {
			SetThreadPriority(GetCurrentThread(), was);
			throw ex;
		} catch (...) {
			qCtxEx ex(354, "Unknown exception during priority shift");
			SetThreadPriority(GetCurrentThread(), was);
			throw ex;
		}

		SetThreadPriority(GetCurrentThread(), was);
	}
}
開發者ID:BackupTheBerlios,項目名稱:smx-svn,代碼行數:50,代碼來源:core.cpp

示例12: ThreadProc

//--------------------------------------------------------------------
// ThreadProc() - 本例之 5 個 threads 共用之 thread procedure
//--------------------------------------------------------------------
VOID ThreadProc(DWORD *ThreadArg)
{
RECT rect;
HDC  hDC;
HANDLE hBrush, hOldBrush;
DWORD dwThreadHits = 0;
char  cBuf[80];
int   iThreadNo, i;

   GetClientRect (_hWnd, &rect);
   hDC = GetDC (_hWnd);
   hBrush = CreateSolidBrush(RGB(*(ThreadArg), *(ThreadArg), *(ThreadArg)));  // 變化畫刷顏色
   hOldBrush = SelectObject(hDC, hBrush);

   switch (*ThreadArg) {
     case HIGHEST_THREAD   : iThreadNo = 0; break;
     case ABOVE_AVE_THREAD : iThreadNo = 1; break;
     case NORMAL_THREAD    : iThreadNo = 2; break;
     case BELOW_AVE_THREAD : iThreadNo = 3; break;
     case LOWEST_THREAD    : iThreadNo = 4; break;
   }

   // 顯示 thread 號碼及其優先權 (priority)
   wsprintf(cBuf, "T%d", iThreadNo);
   TextOut(hDC, *(ThreadArg), rect.bottom-150, cBuf, lstrlen(cBuf));
   wsprintf(cBuf, "P=%d", GetThreadPriority(_hThread[iThreadNo]));
   TextOut(hDC, *(ThreadArg), rect.bottom-130, cBuf, lstrlen(cBuf));

   do
   {
     dwThreadHits++;       // 計數器

     // 畫出四方形,代表 thread 的進行
     Rectangle(hDC, *(ThreadArg), rect.bottom-(dwThreadHits/10),
               *(ThreadArg)+0x40, rect.bottom);

     // 延遲...
     if (_uDelayType == SLEEPDELAY)
         Sleep(10);
     else if (_uDelayType == FORLOOPDELAY)
         for (i=0; i<30000; i++);
     else // _uDelayType == NODELAY)
         {   }
   } while (dwThreadHits < 1000);      // 巡迴  1000 次

   hBrush = SelectObject(hDC, hOldBrush);   // 恢復畫刷顏色
   DeleteObject (hBrush);
   ReleaseDC (_hWnd, hDC);
}
開發者ID:alannet,項目名稱:example,代碼行數:52,代碼來源:MLTITHRD.C

示例13: initialize_thread_priority

/**
 * Initialize a thread's priority.
 *
 * Here the threading library priority value is converted to the appropriate
 * OS-specific value.
 *
 * @param[in] thread a thread
 * @return none
 *
 */
void
initialize_thread_priority(omrthread_t thread)
{
	int priority;

	thread->priority = J9THREAD_PRIORITY_NORMAL;

	if (priority_map[J9THREAD_PRIORITY_MIN] == priority_map[J9THREAD_PRIORITY_MAX]) {
		return;
	}

	priority = GetThreadPriority(thread->handle);

	thread->priority = omrthread_map_native_priority(priority);
}
開發者ID:LinHu2016,項目名稱:omr,代碼行數:25,代碼來源:thrdsup.c

示例14: pthread_getschedparam

int pthread_getschedparam(pthread_t thread, int* policy, struct sched_param* param)
{
	if(policy)
	{
		DWORD pc = GetPriorityClass(GetCurrentProcess());
		*policy = (pc >= HIGH_PRIORITY_CLASS)? SCHED_FIFO : SCHED_RR;
	}
	if(param)
	{
		const HANDLE hThread = HANDLE_from_pthread(thread);
		param->sched_priority = GetThreadPriority(hThread);
	}

	return 0;
}
開發者ID:2asoft,項目名稱:0ad,代碼行數:15,代碼來源:wpthread.cpp

示例15: GetThreadPriority

ThreadPriority HThread::GetPriority() const
{
    Int iWinPriority = GetThreadPriority( m_hThreadingObject );
    DebugAssert( iWinPriority != THREAD_PRIORITY_ERROR_RETURN );

    switch( iWinPriority ) {
        case THREAD_PRIORITY_IDLE:          return THREAD_PRIORITY_IDLETIME;
        case THREAD_PRIORITY_LOWEST:        return THREAD_PRIORITY_VERYLOW;
        case THREAD_PRIORITY_BELOW_NORMAL:  return THREAD_PRIORITY_LOW;
        case THREAD_PRIORITY_NORMAL:        return THREAD_PRIORITY_DEFAULT;
        case THREAD_PRIORITY_ABOVE_NORMAL:  return THREAD_PRIORITY_HIGH;
        case THREAD_PRIORITY_HIGHEST:       return THREAD_PRIORITY_VERYHIGH;
        case THREAD_PRIORITY_TIME_CRITICAL: return THREAD_PRIORITY_REALTIME;
        default: DebugAssert( false ); return THREAD_PRIORITY_DEFAULT;
    }
}
開發者ID:Shikifuyin,項目名稱:Scarab-Engine,代碼行數:16,代碼來源:Threading.cpp


注:本文中的GetThreadPriority函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。