当前位置: 首页>>代码示例>>C++>>正文


C++ ThreadData::iEntryPoint方法代码示例

本文整理汇总了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;
}
开发者ID:broonie,项目名称:ohNet,代码行数:33,代码来源:Os.c

示例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, &param);
        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;
}
开发者ID:MatthewMiddleweek,项目名称:ohNet,代码行数:53,代码来源:Os.c

示例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, &param);
        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;
}
开发者ID:astaykov,项目名称:ohNet,代码行数:39,代码来源:Os.c


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