pub struct Semaphore(/* private fields */);
Expand description
General Zephyr Semaphores
Implementations§
Source§impl Semaphore
impl Semaphore
Sourcepub const fn new(initial_count: c_uint, limit: c_uint) -> Semaphore
pub const fn new(initial_count: c_uint, limit: c_uint) -> Semaphore
Create a new semaphore.
Create a new dynamically allocated Semaphore. This semaphore can only be used from system threads. The arguments are as described in the docs.
Note that this API has changed, and it now doesn’t return a Result, since the Result time generally doesn’t work (in stable rust) with const.
Sourcepub fn take<T>(&self, timeout: T) -> Result<()>
pub fn take<T>(&self, timeout: T) -> Result<()>
Take a semaphore.
Can be called from ISR if called with NoWait
.
Sourcepub fn take_async<'a>(
&'a self,
timeout: impl Into<Timeout>,
) -> impl Future<Output = Result<()>> + 'a
pub fn take_async<'a>( &'a self, timeout: impl Into<Timeout>, ) -> impl Future<Output = Result<()>> + 'a
Take a semaphore, async version.
Returns a future that either waits for the semaphore, or returns status.
Sourcepub fn give(&self)
pub fn give(&self)
Give a semaphore.
This routine gives to the semaphore, unless the semaphore is already at its maximum permitted count.
Trait Implementations§
impl Send for Semaphore
impl Sync for Semaphore
By nature, Semaphores are both Sync and Send. Safety is handled by the underlying Zephyr implementation (which is why Clone is also implemented).