本文整理汇总了C++中GetThreadPriority函数的典型用法代码示例。如果您正苦于以下问题:C++ GetThreadPriority函数的具体用法?C++ GetThreadPriority怎么用?C++ GetThreadPriority使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetThreadPriority函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: ResumeOtherThreads
//=========================================================================
// Internal function:
//
// Resumes all previously suspended threads in the current process.
//=========================================================================
static VOID ResumeOtherThreads() {
// make sure things go as fast as possible
INT nOriginalPriority = GetThreadPriority(GetCurrentThread());
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
// go through our list
for (DWORD i=0; i<g_nThreadHandles; i++) {
// and resume & close thread handles
ResumeThread(g_hThreadHandles[i]);
CloseHandle(g_hThreadHandles[i]);
}
// clean up
free(g_hThreadHandles);
g_hThreadHandles = NULL;
g_nThreadHandles = 0;
SetThreadPriority(GetCurrentThread(), nOriginalPriority);
}
开发者ID:jschmer,项目名称:mhook,代码行数:21,代码来源:mhook.cpp
示例17: GetThreadPriority
//---------------------------------------------------------------------------
tTVPThreadPriority tTVPThread::GetPriority()
{
int n = GetThreadPriority(Handle);
switch(n)
{
case THREAD_PRIORITY_IDLE: return ttpIdle;
case THREAD_PRIORITY_LOWEST: return ttpLowest;
case THREAD_PRIORITY_BELOW_NORMAL: return ttpLower;
case THREAD_PRIORITY_NORMAL: return ttpNormal;
case THREAD_PRIORITY_ABOVE_NORMAL: return ttpHigher;
case THREAD_PRIORITY_HIGHEST: return ttpHighest;
case THREAD_PRIORITY_TIME_CRITICAL: return ttpTimeCritical;
}
return ttpNormal;
}
开发者ID:LonghronShen,项目名称:krkrz,代码行数:17,代码来源:ThreadImpl.cpp
示例18: zactor_new
zactor_t *
zactor_new (zactor_fn *actor, void *args)
{
zactor_t *self = (zactor_t *) zmalloc (sizeof (zactor_t));
if (!self)
return NULL;
self->tag = ZACTOR_TAG;
shim_t *shim = (shim_t *) zmalloc (sizeof (shim_t));
if (!shim) {
zactor_destroy (&self);
return NULL;
}
shim->pipe = zsys_create_pipe (&self->pipe);
shim->handler = actor;
shim->args = args;
#if defined (__UNIX__)
pthread_t thread;
pthread_create (&thread, NULL, s_thread_shim, shim);
pthread_detach (thread);
#elif defined (__WINDOWS__)
HANDLE handle = (HANDLE) _beginthreadex (
NULL, // Handle is private to this process
0, // Use a default stack size for new thread
&s_thread_shim, // Start real thread function via this shim
shim, // Which gets arguments shim
CREATE_SUSPENDED, // Set thread priority before starting it
NULL); // We don't use the thread ID
assert (handle);
// Set child thread priority to same as current
int priority = GetThreadPriority (GetCurrentThread ());
SetThreadPriority (handle, priority);
// Start thread & release resources
ResumeThread (handle);
CloseHandle (handle);
#endif
// Mandatory handshake for new actor so that constructor returns only
// when actor has also initialized. This eliminates timing issues at
// application start up.
zsock_wait (self->pipe);
return self;
}
开发者ID:Cargo-Labs,项目名称:czmq,代码行数:47,代码来源:zactor.c
示例19: tMPI_Thread_create
int tMPI_Thread_create(tMPI_Thread_t *thread,
void *(*start_routine)(void *), void *arg)
{
DWORD thread_id;
struct tMPI_Thread_starter_param *prm;
tMPI_Init_initers();
/* a small memory leak to be sure that it doesn't get deallocated
once this function ends, before the newly created thread uses it. */
prm=(struct tMPI_Thread_starter_param*)
tMPI_Malloc(sizeof(struct tMPI_Thread_starter_param));
prm->start_routine= start_routine;
prm->param=arg;
*thread=(struct tMPI_Thread*)tMPI_Malloc(sizeof(struct tMPI_Thread)*1);
if(thread==NULL)
{
tMPI_Fatal_error(TMPI_FARGS,"Invalid thread pointer.");
return EINVAL;
}
/* just create a plain thread. */
(*thread)->th = CreateThread(NULL,
0,
tMPI_Win32_thread_starter,
prm,
0,
&thread_id);
if((*thread)->th==NULL)
{
tMPI_Free(thread);
tMPI_Fatal_error(TMPI_FARGS,"Failed to create thread, error code=%d",
GetLastError());
return -1;
}
/* inherit the thread priority from the parent thread. */
/* TODO: is there value in setting this, vs. just allowing it to default
from the process? currently, this limits the effectivenes of changing
the priority in eg: TaskManager. */
SetThreadPriority(((*thread)->th), GetThreadPriority(GetCurrentThread()));
return 0;
}
开发者ID:BradleyDickson,项目名称:ABPenabledGROMACS,代码行数:46,代码来源:winthreads.c
示例20: performance_measure
double performance_measure(F f)
{
unsigned count = 1;
double time, result;
#ifdef _WIN32
int old_priority = GetThreadPriority(GetCurrentThread());
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
#endif
//
// Begin by figuring out how many times to repeat
// the function call in order to get a measureable time:
//
do
{
boost::timer t;
for(unsigned i = 0; i < count; ++i)
f();
time = t.elapsed();
count *= 2;
t.restart();
}while(time < 0.5);
count /= 2;
result = time;
//
// Now repeat the measurement over and over
// and take the shortest measured time as the
// result, generally speaking this gives us
// consistent results:
//
for(unsigned i = 0; i < 20u;++i)
{
boost::timer t;
for(unsigned i = 0; i < count; ++i)
f();
time = t.elapsed();
if(time < result)
result = time;
t.restart();
}
#ifdef _WIN32
SetThreadPriority(GetCurrentThread(), old_priority);
#endif
return result / count;
}
开发者ID:0xDEC0DE8,项目名称:mcsema,代码行数:45,代码来源:performance_measure.hpp
注:本文中的GetThreadPriority函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论