Ignore:
Timestamp:
Mar 4, 2008 2:45:19 PM (16 years ago)
Author:
bennylp
Message:

Ticket #500: Added function to set thread priority in PJLIB

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib/src/pj/os_core_win32.c

    r1659 r1841  
    254254} 
    255255 
     256 
     257/* 
     258 * Get thread priority value for the thread. 
     259 */ 
     260PJ_DEF(int) pj_thread_get_prio(pj_thread_t *thread) 
     261{ 
     262    return GetThreadPriority(thread->hthread); 
     263} 
     264 
     265 
     266/* 
     267 * Set the thread priority. 
     268 */ 
     269PJ_DEF(pj_status_t) pj_thread_set_prio(pj_thread_t *thread,  int prio) 
     270{ 
     271#if PJ_HAS_THREADS 
     272    PJ_ASSERT_RETURN(thread, PJ_EINVAL); 
     273    PJ_ASSERT_RETURN(prio>=THREAD_PRIORITY_IDLE &&  
     274                        prio<=THREAD_PRIORITY_TIME_CRITICAL, 
     275                     PJ_EINVAL); 
     276 
     277    if (SetThreadPriority(thread->hthread, prio) == FALSE) 
     278        return PJ_RETURN_OS_ERROR(GetLastError()); 
     279 
     280    return PJ_SUCCESS; 
     281 
     282#else 
     283    PJ_UNUSED_ARG(thread); 
     284    PJ_UNUSED_ARG(prio); 
     285    pj_assert("pj_thread_set_prio() called in non-threading mode!"); 
     286    return PJ_EINVALIDOP; 
     287#endif 
     288} 
     289 
     290 
     291/* 
     292 * Get the lowest priority value available on this system. 
     293 */ 
     294PJ_DEF(int) pj_thread_get_prio_min(pj_thread_t *thread) 
     295{ 
     296    PJ_UNUSED_ARG(thread); 
     297    return THREAD_PRIORITY_IDLE; 
     298} 
     299 
     300 
     301/* 
     302 * Get the highest priority value available on this system. 
     303 */ 
     304PJ_DEF(int) pj_thread_get_prio_max(pj_thread_t *thread) 
     305{ 
     306    PJ_UNUSED_ARG(thread); 
     307    return THREAD_PRIORITY_TIME_CRITICAL; 
     308} 
     309 
     310 
    256311/* 
    257312 * Get native thread handle 
Note: See TracChangeset for help on using the changeset viewer.