Trait thread_priority::unix::ThreadExt
source · [−]pub trait ThreadExt {
fn get_priority(&self) -> Result<ThreadPriority, Error> { ... }
fn set_priority(&self, priority: ThreadPriority) -> Result<(), Error> { ... }
fn get_schedule_policy(&self) -> Result<ThreadSchedulePolicy, Error> { ... }
fn get_schedule_policy_param(
&self
) -> Result<(ThreadSchedulePolicy, ScheduleParams), Error> { ... }
fn set_schedule_policy(
&self,
policy: ThreadSchedulePolicy,
priority: ThreadPriority
) -> Result<(), Error> { ... }
fn get_native_id(&self) -> ThreadId { ... }
}
Expand description
A helper trait for other threads to implement to be able to call methods on threads themselves.
use thread_priority::*;
assert!(std::thread::current().get_priority().is_ok());
let join_handle = std::thread::spawn(|| println!("Hello world!"));
assert!(join_handle.thread().get_priority().is_ok());
join_handle.join();
Provided methods
fn get_priority(&self) -> Result<ThreadPriority, Error>
fn get_priority(&self) -> Result<ThreadPriority, Error>
Gets the current thread’s priority.
For more info read get_current_thread_priority
.
use thread_priority::*;
assert!(std::thread::current().get_priority().is_ok());
fn set_priority(&self, priority: ThreadPriority) -> Result<(), Error>
fn set_priority(&self, priority: ThreadPriority) -> Result<(), Error>
Sets the current thread’s priority.
For more info see ThreadPriority::set_for_current
.
use thread_priority::*;
assert!(std::thread::current().set_priority(ThreadPriority::Min).is_ok());
fn get_schedule_policy(&self) -> Result<ThreadSchedulePolicy, Error>
fn get_schedule_policy(&self) -> Result<ThreadSchedulePolicy, Error>
Gets the current thread’s schedule policy.
For more info read thread_schedule_policy
.
fn get_schedule_policy_param(
&self
) -> Result<(ThreadSchedulePolicy, ScheduleParams), Error>
fn get_schedule_policy_param(
&self
) -> Result<(ThreadSchedulePolicy, ScheduleParams), Error>
Returns current thread’s schedule policy and parameters.
For more info read thread_schedule_policy_param
.
fn set_schedule_policy(
&self,
policy: ThreadSchedulePolicy,
priority: ThreadPriority
) -> Result<(), Error>
fn set_schedule_policy(
&self,
policy: ThreadSchedulePolicy,
priority: ThreadPriority
) -> Result<(), Error>
Sets current thread’s schedule policy.
For more info read set_thread_schedule_policy
.
fn get_native_id(&self) -> ThreadId
fn get_native_id(&self) -> ThreadId
Returns native unix thread id.
For more info read thread_native_id
.
use thread_priority::*;
assert!(std::thread::current().get_native_id() > 0);
Implementations on Foreign Types
Auto-implementation of this trait for the std::thread::Thread
.