本文整理汇总了C++中ThreadData::iEntryPoint方法的典型用法代码示例。如果您正苦于以下问题:C++ ThreadData::iEntryPoint方法的具体用法?C++ ThreadData::iEntryPoint怎么用?C++ ThreadData::iEntryPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ThreadData
的用法示例。
在下文中一共展示了ThreadData::iEntryPoint方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: threadEntrypoint
DWORD threadEntrypoint(LPVOID aArg)
{
ThreadData* data = (ThreadData*)aArg;
int priority = THREAD_PRIORITY_NORMAL;
static const int kHostPriorities[] = { THREAD_PRIORITY_IDLE
,THREAD_PRIORITY_LOWEST
,THREAD_PRIORITY_BELOW_NORMAL
,THREAD_PRIORITY_NORMAL
,THREAD_PRIORITY_ABOVE_NORMAL
,THREAD_PRIORITY_HIGHEST
,THREAD_PRIORITY_TIME_CRITICAL };
static const int kNumHostPriorities = sizeof(kHostPriorities) / sizeof(kHostPriorities[0]);
int step = (kPriorityMax - kPriorityMin) / kNumHostPriorities;
int i;
assert(data != NULL);
for (i=kNumHostPriorities-1; i>=0; i--) {
if (kPriorityMin + (i*step) < data->iPriority) {
priority = kHostPriorities[i];
break;
}
}
if (!SetThreadPriority(data->iThread, priority)) {
//fprintf(stderr, "SetPriority failed (err=%d)\n", GetLastError());
//fflush(stderr);
}
(void)TlsSetValue(data->iCtx->iTlsIndex, data->iArg);
data->iEntryPoint(data->iArg);
return 0;
}
示例2: threadEntrypoint
static void* threadEntrypoint(void* aArg)
{
#ifndef __ANDROID__
int oldState;
int status;
#endif
ThreadData* data = (ThreadData*)aArg;
assert(data != NULL);
#if defined(ATTEMPT_THREAD_PRIORITIES)
{
TInt platMin = sched_get_priority_min(kThreadSchedPolicy);
TInt platMax = sched_get_priority_max(kThreadSchedPolicy);
// convert the UPnP library's 50 - 150 priority range into
// an equivalent posix priority
// ...calculate priority as percentage of library range
int32_t percent = (((int32_t )data->iPriority - 50) * 100) / (150 - 50);
// ...calculate native priority as 'percent' through the dest range
int32_t priority = platMin + ((percent * (platMax - platMin))/100);
sched_param param;
param.sched_priority = priority;
int status = pthread_setschedparam(data->iThread, kThreadSchedPolicy, ¶m);
assert(status == 0);
}
#elif defined(ATTEMPT_THREAD_NICENESS) // ATTEMPT_THREAD_PRIORITIES
{
static const int kMinimumNice = 5; // set MIN
// Map all prios > 105 -> nice 0 (default), anything else to MIN
//int nice_value = (data->iPriority > 105 ? 0 : kMinimumNice);
// Map prio=[50,150]-> nice=[MIN,0]
int nice_value = -1 * (((((int) data->iPriority-50) * kMinimumNice) / (150-50)) - kMinimumNice);
if ( nice_value < 0 )
nice_value = 0;
//printf("Thread of priority %d asking for niceness %d (current niceness is %d)\n", data->iPriority, nice_value, getpriority(PRIO_PROCESS, 0));
int result = setpriority(PRIO_PROCESS, 0, nice_value);
//if ( result == -1 )
// perror("Warning: Could not renice this thread");
}
#endif
// Disable cancellation - we're in a C++ environment, and
// don't want to rely on pthreads to mess things up for us.
#ifndef __ANDROID__
status = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldState);
assert(status == 0);
#endif
//tlsThreadArg = data->iArg;
pthread_setspecific(data->iCtx->iThreadArgKey, data->iArg);
data->iEntryPoint(data->iArg);
return NULL;
}
示例3: threadEntrypoint
static void* threadEntrypoint(void* aArg)
{
#ifndef __ANDROID__
int oldState;
int status;
#endif
ThreadData* data = (ThreadData*)aArg;
assert(data != NULL);
#ifdef ATTEMPT_THREAD_PRIORITIES
{
TInt platMin = sched_get_priority_min(kThreadSchedPolicy);
TInt platMax = sched_get_priority_max(kThreadSchedPolicy);
// convert the UPnP library's 50 - 150 priority range into
// an equivalent posix priority
// ...calculate priority as percentage of library range
int32_t percent = (((int32_t )data->iPriority - 50) * 100) / (150 - 50);
// ...calculate native priority as 'percent' through the dest range
int32_t priority = platMin + ((percent * (platMax - platMin))/100);
sched_param param;
param.sched_priority = priority;
int status = pthread_setschedparam(data->iThread, kThreadSchedPolicy, ¶m);
assert(status == 0);
}
#endif // ATTEMPT_THREAD_PRIORITIES
// Disable cancellation - we're in a C++ environment, and
// don't want to rely on pthreads to mess things up for us.
#ifndef __ANDROID__
status = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldState);
assert(status == 0);
#endif
//tlsThreadArg = data->iArg;
pthread_setspecific(gThreadArgKey, data->iArg);
data->iEntryPoint(data->iArg);
return NULL;
}