diff options
author | Benny Prijono <bennylp@teluu.com> | 2008-03-04 14:45:19 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2008-03-04 14:45:19 +0000 |
commit | 5254d7c3a14177dffdf43c3ec7e5235b066d986e (patch) | |
tree | 249ea16a1ab2e6d7693c56af6d9af5516590b589 /pjlib/src/pj/os_core_win32.c | |
parent | 771571a57c706e924ba3511dbf6c6e3dbda93c68 (diff) |
Ticket #500: Added function to set thread priority in PJLIB
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1841 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib/src/pj/os_core_win32.c')
-rw-r--r-- | pjlib/src/pj/os_core_win32.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/pjlib/src/pj/os_core_win32.c b/pjlib/src/pj/os_core_win32.c index 4bc8a970..80c24604 100644 --- a/pjlib/src/pj/os_core_win32.c +++ b/pjlib/src/pj/os_core_win32.c @@ -253,6 +253,61 @@ PJ_DEF(pj_bool_t) pj_thread_is_registered(void) return pj_thread_local_get(thread_tls_id) != 0; } + +/* + * Get thread priority value for the thread. + */ +PJ_DEF(int) pj_thread_get_prio(pj_thread_t *thread) +{ + return GetThreadPriority(thread->hthread); +} + + +/* + * Set the thread priority. + */ +PJ_DEF(pj_status_t) pj_thread_set_prio(pj_thread_t *thread, int prio) +{ +#if PJ_HAS_THREADS + PJ_ASSERT_RETURN(thread, PJ_EINVAL); + PJ_ASSERT_RETURN(prio>=THREAD_PRIORITY_IDLE && + prio<=THREAD_PRIORITY_TIME_CRITICAL, + PJ_EINVAL); + + if (SetThreadPriority(thread->hthread, prio) == FALSE) + return PJ_RETURN_OS_ERROR(GetLastError()); + + return PJ_SUCCESS; + +#else + PJ_UNUSED_ARG(thread); + PJ_UNUSED_ARG(prio); + pj_assert("pj_thread_set_prio() called in non-threading mode!"); + return PJ_EINVALIDOP; +#endif +} + + +/* + * Get the lowest priority value available on this system. + */ +PJ_DEF(int) pj_thread_get_prio_min(pj_thread_t *thread) +{ + PJ_UNUSED_ARG(thread); + return THREAD_PRIORITY_IDLE; +} + + +/* + * Get the highest priority value available on this system. + */ +PJ_DEF(int) pj_thread_get_prio_max(pj_thread_t *thread) +{ + PJ_UNUSED_ARG(thread); + return THREAD_PRIORITY_TIME_CRITICAL; +} + + /* * Get native thread handle */ |