Struct nysa::Bus [−][src]
pub struct Bus { /* fields omitted */ }
Expand description
A bus for passing messages across threads.
Nysa buses are fully thread-safe, and thus, can be stored in static
variables. The library
provides a “default” bus in the module crate::global
.
Implementations
Pushes a message with the given data onto the bus.
Retrieves all messages of the given type from the bus.
Note that the bus for the given message type is locked for the entire duration of this loop.
See also
Blocks execution in the current thread indefinitely until a message of the provided type arrives on the bus.
Although the Rust style guidelines say otherwise, to prevent bugs and aid readability it’s best to always use the turbofish syntax over implicit type inference with this function, such that it’s immediately visible what type of message is being waited for.
See also
Blocks execution in the current thread until a message of the provided type arrives on the bus, or the given timeout is reached.
This function will block for the specified amount of time at most and resume execution normally. Otherwise it will block indefinitely.
Returns Some(data)
if data was successfully fetched, or None
if the timeout was reached.