Expand description
Task utility functions.
Re-exports§
pub use thread_priority;pub use self;
Modules§
- unix
Android or DragonFly BSD or FreeBSD or iOS or Linux or macOS or NetBSD or OpenBSD or VxWorks or WebAssembly - This module defines the unix thread control.
Structs§
- Deadline
Flags Android or DragonFly BSD or FreeBSD or iOS or Linux or macOS or NetBSD or OpenBSD or VxWorks or WebAssembly - Flags for controlling Deadline scheduling behavior.
- Sched
Attr (Android or DragonFly BSD or FreeBSD or iOS or Linux or macOS or NetBSD or OpenBSD or VxWorks or WebAssembly) and (Android or Linux) - A copy of the Linux kernel’s sched_attr type.
- Schedule
Params Android or DragonFly BSD or FreeBSD or iOS or Linux or macOS or NetBSD or OpenBSD or VxWorks or WebAssembly - Proxy structure to maintain compatibility between glibc and musl
- Thread
- Represents an OS thread.
- Thread
Builder - A copy of the
std::thread::Builderbuilder allowing to set priority settings. - Thread
Priority OsValue - Platform-specific thread priority value.
- Thread
Priority Value - Platform-independent thread priority value.
Should be in
[0; 100)range. The higher the number is - the higher the priority.
Enums§
- Error
- A error type
- Normal
Thread Schedule Policy Android or DragonFly BSD or FreeBSD or iOS or Linux or macOS or NetBSD or OpenBSD or VxWorks or WebAssembly - Normal (non-realtime) schedule policies
For these schedule policies,
nicenessis used. - Priority
Policy Edge Value Type Android or DragonFly BSD or FreeBSD or iOS or Linux or macOS or NetBSD or OpenBSD or VxWorks or WebAssembly - Defines the type of the priority edge value: minimum or maximum.
- Realtime
Thread Schedule Policy Android or DragonFly BSD or FreeBSD or iOS or Linux or macOS or NetBSD or OpenBSD or VxWorks or WebAssembly - The following “real-time” policies are also supported, for special time-critical applications that need precise control over the way in which runnable processes are selected for execution
- Thread
Priority - Thread priority enumeration.
- Thread
Schedule Policy Android or DragonFly BSD or FreeBSD or iOS or Linux or macOS or NetBSD or OpenBSD or VxWorks or WebAssembly - Thread schedule policy definition.
Constants§
- NICENESS_
MAX Android or DragonFly BSD or FreeBSD or iOS or Linux or macOS or NetBSD or OpenBSD or VxWorks or WebAssembly - The maximum value possible for niceness. Threads with this value of niceness have the highest priority possible
- NICENESS_
MIN Android or DragonFly BSD or FreeBSD or iOS or Linux or macOS or NetBSD or OpenBSD or VxWorks or WebAssembly - The minimum value possible for niceness. Threads with this value of niceness have the lowest priority possible.
Traits§
- Thread
Builder Ext - Adds thread building functions using the priority.
- Thread
Ext Android or DragonFly BSD or FreeBSD or iOS or Linux or macOS or NetBSD or OpenBSD or VxWorks or WebAssembly - A helper trait for other threads to implement to be able to call methods on threads themselves.
- Thread
Scope Ext - Adds scoped thread building functions using the priority.
Functions§
- deprioritize_
background_ threads - Deprioritizes known background threads spawned by third-party libraries (
tracing-appender,reqwest) by scanning/proc/<pid>/task/for matching thread names and settingSCHED_IDLEscheduling policy on them. - get_
current_ thread_ priority Android or DragonFly BSD or FreeBSD or iOS or Linux or macOS or NetBSD or OpenBSD or VxWorks or WebAssembly - Get current thread’s priority value.
- get_
thread_ priority Android or DragonFly BSD or FreeBSD or iOS or Linux or macOS or NetBSD or OpenBSD or VxWorks or WebAssembly - Get the thread’s priority value.
- get_
thread_ scheduling_ attributes (Android or DragonFly BSD or FreeBSD or iOS or Linux or macOS or NetBSD or OpenBSD or VxWorks or WebAssembly) and (Android or Linux) - Returns scheduling attributes for the current thread.
- increase_
thread_ priority - Increases the current thread’s priority.
- set_
current_ thread_ priority Android or DragonFly BSD or FreeBSD or iOS or Linux or macOS or NetBSD or OpenBSD or VxWorks or WebAssembly - Set current thread’s priority. In order to properly map a value of the thread priority, the thread scheduling must be known. This function attempts to retrieve the current thread’s scheduling policy and thus map the priority value correctly, so that it fits within the scheduling policy’s allowed range of values.
- set_
thread_ priority_ and_ policy Android or DragonFly BSD or FreeBSD or iOS or Linux or macOS or NetBSD or OpenBSD or VxWorks or WebAssembly - Sets thread’s priority and schedule policy
- spawn
- Spawns a thread with the specified priority.
- spawn_
careless - Spawns a thread with the specified priority.
This is different from
spawnin a way that the passed function doesn’t need to accept theThreadPriority::set_for_currentresult. In case of an error, the error is logged using the logging facilities. - spawn_
scoped - Spawns a scoped thread with the specified priority.
- spawn_
scoped_ careless - Spawns a scoped thread with the specified priority.
This is different from
spawn_scopedin a way that the passed function doesn’t need to accept theThreadPriority::set_for_currentresult. In case of an error, the error is logged using the logging facilities. - thread_
native_ id Android or DragonFly BSD or FreeBSD or iOS or Linux or macOS or NetBSD or OpenBSD or VxWorks or WebAssembly - Returns current thread id, which is the current OS’s native handle. It may or may not be equal or even related to rust’s thread id, there is absolutely no guarantee for that.
- thread_
schedule_ policy Android or DragonFly BSD or FreeBSD or iOS or Linux or macOS or NetBSD or OpenBSD or VxWorks or WebAssembly - Returns policy parameters (schedule policy and other schedule parameters) for current process
- thread_
schedule_ policy_ param Android or DragonFly BSD or FreeBSD or iOS or Linux or macOS or NetBSD or OpenBSD or VxWorks or WebAssembly - Returns policy parameters (schedule policy and other schedule parameters)
Type Aliases§
- Thread
Id Android or DragonFly BSD or FreeBSD or iOS or Linux or macOS or NetBSD or OpenBSD or VxWorks or WebAssembly - An alias type for a thread id.