pub struct Signal<M, T>where
    M: RawMutex,
{ /* private fields */ }
Expand description

Single-slot signaling primitive.

This is similar to a Channel with a buffer size of 1, except “sending” to it (calling Signal::signal) when full will overwrite the previous value instead of waiting for the receiver to pop the previous value.

It is useful for sending data between tasks when the receiver only cares about the latest data, and therefore it’s fine to “lose” messages. This is often the case for “state” updates.

For more advanced use cases, you might want to use Channel instead.

Signals are generally declared as statics and then borrowed as required.

use embassy_sync::signal::Signal;
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;

enum SomeCommand {
  On,
  Off,
}

static SOME_SIGNAL: Signal<CriticalSectionRawMutex, SomeCommand> = Signal::new();

Implementations

Create a new Signal.

Mark this Signal as signaled.

Remove the queued value in this Signal, if any.

Future that completes when this Signal has been signaled.

non-blocking method to check whether this signal has been signaled.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.