pub struct Signal { /* private fields */ }
Expand description
A semaphore-like asynchronous inter-process communication primitive.
Each signal has 32-bit-wide bitfields. Updating the bitfields wakes up waiting processes. You can update the bitfields multiple times before it is cleared, but it can’t tell how many times it was updated. In other words, it guarantees bitfields are set at least once.
§Signal
vs. Channel
While Signal
cannot carry data more than bitfields,
it is more lightweight and faster than Channel
.
Use Signal
when you need to notify other processes of an event, especially when you just want to wake up a sleeping process.
Implementations§
Source§impl Signal
impl Signal
Sourcepub fn from_handle(handle: OwnedHandle) -> Signal
pub fn from_handle(handle: OwnedHandle) -> Signal
Instantiates the object from the given handle.
Sourcepub fn handle(&self) -> &OwnedHandle
pub fn handle(&self) -> &OwnedHandle
Returns the handle.
Sourcepub fn update(&self, value: SignalBits) -> Result<(), FtlError>
pub fn update(&self, value: SignalBits) -> Result<(), FtlError>
Updates the signal. Non-blocking.
This bit-wise ORs the given value to the signal, and wakes up waiting processes if any.
Sourcepub fn clear(&self) -> Result<SignalBits, FtlError>
pub fn clear(&self) -> Result<SignalBits, FtlError>
Clears the signal, and returns the previous value. Non-blocking.