thread-priority
A simple library to control thread schedule policies and thread priority.
If your operating system isn't yet supported, please, create an issue.
Minimal Rust Compiler Version
Is 1.46
. If you need any help making it possible to compile with 1.36
please reach out.
Supported platforms
- Linux
- Android
- DragonFly
- FreeBSD
- OpenBSD
- NetBSD
- macOS
- Windows
Examples
Minimal cross-platform examples
Setting current thread's priority to minimum:
use *;
The same as above but using a specific value:
use *;
use TryInto;
Windows-specific examples
Set the thread priority to the lowest possible value:
use *;
Set the ideal processor for the new thread:
use *;
Building a thread using the ThreadBuilderExt trait
use *;
use ThreadBuilderExt;
let thread = new
.name
.spawn_with_priority.unwrap;
thread.join;
Building a thread using the ThreadBuilder.
use *;
let thread = default
.name
.priority
.spawn.unwrap;
thread.join;
// Another example where we don't care about the priority having been set.
let thread = default
.name
.priority
.spawn_careless.unwrap;
thread.join;
Using ThreadExt trait on the current thread
use *;
assert!;
println!;
License
This project is licensed under the MIT license.