Module drone_core::thr [−][src]
The Threads module.
NOTE A Drone platform crate may re-export this module with its own additions under the same name, in which case it should be used instead.
Drone is a hard real-time operating system. It uses preemptive priority scheduling, where tasks with same priorities are executed cooperatively. A task unit, called Fiber in Drone, is a stack-less co-routine programmed with Rust async/await and/or generator syntax.
The number of threads is always static but configurable. Any number of
fibers can be attached to a particular thread, see fib
for
details. The Drone application configures its own thread type, which
implements Thread
, and creates a continuous array of this type.
use drone_core::thr; thr::pool! { /// The thread object. thread => pub Thr { // You can add your own fields to the thread object. These fields will be // accessible through `to_thr` method of thread tokens. The types of // these fields should be `Sync`. pub foo: bool = false; }; // This is a part of `Thr` that can be accessed with `thr::local` function. /// The thread-local storage. local => pub ThrLocal { // You can add your own fields here with the same syntax as above. // Note that the initializer uses the special `index` variable, that // has the value of the position of the thread within the threads array. // The types of these fields shouldn't necessarily be `Sync`. pub bar: u16 = index; }; /// Thread token set. index => pub Thrs; // Thread definitions. threads => { /// Example thread 1. pub thread1; /// Example thread 2. pub thread2; }; }
Modules
prelude | The Threads prelude. |
Macros
pool | Defines a thread pool. |
soft | Defines a software-managed thread pool. |
Structs
LocalOpaque | Thread-local storage wrapper for thread |
Constants
PRIORITY_LEVELS | Number of priority levels. |
Traits
ExecOutput | A trait for implementing arbitrary output types for futures passed to
|
SoftThrToken | Token for a software-managed thread. |
SoftThread | Software-managed thread. |
ThrExec | Thread executor. |
ThrToken | Token for a thread in a thread pool. |
Thread | Basic thread. |
Functions
pending_size | Returns the number of elements in |