- Timestamp:
- Mar 4, 2008 2:45:19 PM (17 years ago)
- Location:
- pjproject/trunk/pjlib
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/include/pj/os.h
r1601 r1841 136 136 */ 137 137 PJ_DECL(pj_bool_t) pj_thread_is_registered(void); 138 139 140 /** 141 * Get thread priority value for the thread. 142 * 143 * @param thread Thread handle. 144 * 145 * @return Thread priority value, or -1 on error. 146 */ 147 PJ_DECL(int) pj_thread_get_prio(pj_thread_t *thread); 148 149 150 /** 151 * Set the thread priority. The priority value must be in the priority 152 * value range, which can be retrieved with #pj_thread_get_prio_min() and 153 * #pj_thread_get_prio_max() functions. 154 * 155 * @param thread Thread handle. 156 * @param prio New priority to be set to the thread. 157 * 158 * @return PJ_SUCCESS on success or the error code. 159 */ 160 PJ_DECL(pj_status_t) pj_thread_set_prio(pj_thread_t *thread, int prio); 161 162 /** 163 * Get the lowest priority value available for this thread. 164 * 165 * @param thread Thread handle. 166 * @return Minimum thread priority value, or -1 on error. 167 */ 168 PJ_DECL(int) pj_thread_get_prio_min(pj_thread_t *thread); 169 170 171 /** 172 * Get the highest priority value available for this thread. 173 * 174 * @param thread Thread handle. 175 * @return Minimum thread priority value, or -1 on error. 176 */ 177 PJ_DECL(int) pj_thread_get_prio_max(pj_thread_t *thread); 138 178 139 179 -
pjproject/trunk/pjlib/src/pj/os_core_symbian.cpp
r1651 r1841 485 485 } 486 486 487 488 /* 489 * Get thread priority value for the thread. 490 */ 491 PJ_DEF(int) pj_thread_get_prio(pj_thread_t *thread) 492 { 493 PJ_UNUSED_ARG(thread); 494 return 1; 495 } 496 497 498 /* 499 * Set the thread priority. 500 */ 501 PJ_DEF(pj_status_t) pj_thread_set_prio(pj_thread_t *thread, int prio) 502 { 503 PJ_UNUSED_ARG(thread); 504 PJ_UNUSED_ARG(prio); 505 return PJ_SUCCESS; 506 } 507 508 509 /* 510 * Get the lowest priority value available on this system. 511 */ 512 PJ_DEF(int) pj_thread_get_prio_min(pj_thread_t *thread) 513 { 514 PJ_UNUSED_ARG(thread); 515 return 1; 516 } 517 518 519 /* 520 * Get the highest priority value available on this system. 521 */ 522 PJ_DEF(int) pj_thread_get_prio_max(pj_thread_t *thread) 523 { 524 PJ_UNUSED_ARG(thread); 525 return 1; 526 } 527 528 487 529 /* 488 530 * pj_thread_get_os_handle() -
pjproject/trunk/pjlib/src/pj/os_core_unix.c
r1783 r1841 239 239 } 240 240 241 242 /* 243 * Get thread priority value for the thread. 244 */ 245 PJ_DEF(int) pj_thread_get_prio(pj_thread_t *thread) 246 { 247 #if PJ_HAS_THREADS 248 sched_param param; 249 int policy; 250 int rc; 251 252 rc = pthread_getschedparam (thread->thread, &policy, ¶m); 253 if (rc != 0) 254 return -1; 255 256 return param.sched_priority; 257 #else 258 PJ_UNUSED_ARG(thread); 259 return 1; 260 #endif 261 } 262 263 264 /* 265 * Set the thread priority. 266 */ 267 PJ_DEF(pj_status_t) pj_thread_set_prio(pj_thread_t *thread, int prio) 268 { 269 #if PJ_HAS_THREADS 270 sched_param param; 271 int policy; 272 int rc; 273 274 rc = pthread_getschedparam (thread->thread, &policy, ¶m); 275 if (rc != 0) 276 return PJ_RETURN_OS_ERROR(rc); 277 278 param.sched_priority = prio; 279 280 rc = pthread_setschedparam(tid, policy, ¶m); 281 if (rc != 0) 282 return PJ_RETURN_OS_ERROR(rc); 283 284 return PJ_SUCCESS; 285 #else 286 PJ_UNUSED_ARG(thread); 287 PJ_UNUSED_ARG(prio); 288 pj_assert("pj_thread_set_prio() called in non-threading mode!"); 289 return 1; 290 #endif 291 } 292 293 294 /* 295 * Get the lowest priority value available on this system. 296 */ 297 PJ_DEF(int) pj_thread_get_prio_min(pj_thread_t *thread) 298 { 299 sched_param param; 300 int policy; 301 int rc; 302 303 rc = pthread_getschedparam(thread->thread, &policy, ¶m); 304 if (rc != 0) 305 return -1; 306 307 return sched_get_priority_min(policy); 308 } 309 310 311 /* 312 * Get the highest priority value available on this system. 313 */ 314 PJ_DEF(int) pj_thread_get_prio_max(pj_thread_t *thread) 315 { 316 sched_param param; 317 int policy; 318 int rc; 319 320 rc = pthread_getschedparam(thread->thread, &policy, ¶m); 321 if (rc != 0) 322 return -1; 323 324 return sched_get_priority_max(policy); 325 } 326 327 241 328 /* 242 329 * Get native thread handle -
pjproject/trunk/pjlib/src/pj/os_core_win32.c
r1659 r1841 254 254 } 255 255 256 257 /* 258 * Get thread priority value for the thread. 259 */ 260 PJ_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 */ 269 PJ_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 */ 294 PJ_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 */ 304 PJ_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 256 311 /* 257 312 * Get native thread handle
Note: See TracChangeset
for help on using the changeset viewer.