pub struct Semaphore { /* private fields */ }
Expand description
A zephyr k_sem
usable from safe Rust code.
Implementations§
source§impl Semaphore
impl Semaphore
sourcepub fn new(initial_count: c_uint, limit: c_uint) -> Result<Semaphore>
pub fn new(initial_count: c_uint, limit: c_uint) -> Result<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.
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 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).
Auto Trait Implementations§
impl Freeze for Semaphore
impl !RefUnwindSafe for Semaphore
impl Unpin for Semaphore
impl UnwindSafe for Semaphore
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more