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

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());

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());

Gets the current thread’s schedule policy. For more info read thread_schedule_policy.

Returns current thread’s schedule policy and parameters. For more info read thread_schedule_policy_param.

Sets current thread’s schedule policy. For more info read set_thread_schedule_policy.

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.

Implementors