Function thread_priority::unix::set_thread_priority_and_policy
source · pub fn set_thread_priority_and_policy(
native: ThreadId,
priority: ThreadPriority,
policy: ThreadSchedulePolicy
) -> Result<(), Error>Expand description
Sets thread’s priority and schedule policy
- May require privileges
Usage
Setting thread priority to minimum with normal schedule policy:
use thread_priority::*;
let thread_id = thread_native_id();
assert!(set_thread_priority_and_policy(thread_id,
ThreadPriority::Min,
ThreadSchedulePolicy::Realtime(RealtimeThreadSchedulePolicy::Fifo)).is_ok());Note
In case the value is specified as ThreadPriority::Crossplatform and is incompatible with the policy, an error is returned.
However if ThreadPriority::Min or ThreadPriority::Max are used, the correct value is used automatically according
to the range of the policy’s allowed values.