mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-05-30 02:20:11 +00:00
FS-6211 thread priority in the apr for windows
This commit is contained in:
parent
729976df27
commit
47a7ef557a
@ -87,6 +87,7 @@ APR_DECLARE(apr_status_t) apr_thread_create(apr_thread_t **new,
|
|||||||
apr_status_t stat;
|
apr_status_t stat;
|
||||||
unsigned temp;
|
unsigned temp;
|
||||||
HANDLE handle;
|
HANDLE handle;
|
||||||
|
int priority = THREAD_PRIORITY_NORMAL;
|
||||||
|
|
||||||
(*new) = (apr_thread_t *)apr_palloc(pool, sizeof(apr_thread_t));
|
(*new) = (apr_thread_t *)apr_palloc(pool, sizeof(apr_thread_t));
|
||||||
|
|
||||||
@ -103,6 +104,18 @@ APR_DECLARE(apr_status_t) apr_thread_create(apr_thread_t **new,
|
|||||||
return stat;
|
return stat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (attr && attr->priority && attr->priority > 0) {
|
||||||
|
if (attr->priority >= 99) {
|
||||||
|
priority = THREAD_PRIORITY_TIME_CRITICAL;
|
||||||
|
} else if (attr->priority >= 50) {
|
||||||
|
priority = THREAD_PRIORITY_ABOVE_NORMAL;
|
||||||
|
} else if (attr->priority >= 10) {
|
||||||
|
priority = THREAD_PRIORITY_NORMAL;
|
||||||
|
} else if (attr->priority >= 1) {
|
||||||
|
priority = THREAD_PRIORITY_LOWEST;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Use 0 for Thread Stack Size, because that will default the stack to the
|
/* Use 0 for Thread Stack Size, because that will default the stack to the
|
||||||
* same size as the calling thread.
|
* same size as the calling thread.
|
||||||
*/
|
*/
|
||||||
@ -121,6 +134,11 @@ APR_DECLARE(apr_status_t) apr_thread_create(apr_thread_t **new,
|
|||||||
return apr_get_os_error();
|
return apr_get_os_error();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (priority) {
|
||||||
|
SetThreadPriority(handle, priority);
|
||||||
|
}
|
||||||
|
|
||||||
if (attr && attr->detach) {
|
if (attr && attr->detach) {
|
||||||
CloseHandle(handle);
|
CloseHandle(handle);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user