提交 f6e591de authored 作者: Jeff Lenk's avatar Jeff Lenk

windows only - add our own thread priority ability for core threads please test

上级 4ad5688a
......@@ -618,12 +618,12 @@ struct apr_threadattr_t {
int priority;
};
#else
/* this needs to be revisited when apr for windows supports thread priority settings */
/* search for WIN32 in this file */
/* we are implementing our own windows support for thread priority settings because apr does not*/
struct apr_threadattr_t {
apr_pool_t *pool;
apr_int32_t detach;
apr_size_t stacksize;
int priority;
};
#endif
......@@ -633,9 +633,7 @@ SWITCH_DECLARE(switch_status_t) switch_threadattr_create(switch_threadattr_t **
switch_status_t status;
if ((status = apr_threadattr_create(new_attr, pool)) == SWITCH_STATUS_SUCCESS) {
#ifndef WIN32
(*new_attr)->priority = SWITCH_PRI_LOW;
#endif
}
return status;
......@@ -653,9 +651,7 @@ SWITCH_DECLARE(switch_status_t) switch_threadattr_stacksize_set(switch_threadatt
SWITCH_DECLARE(switch_status_t) switch_threadattr_priority_set(switch_threadattr_t *attr, switch_thread_priority_t priority)
{
#ifndef WIN32
attr->priority = priority;
#endif
return SWITCH_STATUS_SUCCESS;
}
......@@ -664,8 +660,16 @@ static char TT_KEY[] = "1";
SWITCH_DECLARE(switch_status_t) switch_thread_create(switch_thread_t ** new_thread, switch_threadattr_t *attr,
switch_thread_start_t func, void *data, switch_memory_pool_t *cont)
{
apr_status_t status;
switch_core_memory_pool_set_data(cont, "_in_thread", TT_KEY);
return apr_thread_create(new_thread, attr, func, data, cont);
status = apr_thread_create(new_thread, attr, func, data, cont);
#ifdef WIN32
if (attr->priority == SWITCH_PRI_REALTIME) {
SetThreadPriority(new_thread, THREAD_PRIORITY_HIGHEST);
}
#endif
return (switch_status_t)status;
}
/* socket stubs */
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论