pub struct Semaphore<const MAX: u8> { /* private fields */ }Expand description
An async counting semaphore.
ⓘ
static SEM: rivet::sync::Semaphore<1> = rivet::sync::Semaphore::new(0);
#[rivet::task(priority = 1)]
async fn waiter() {
loop {
SEM.acquire().await;
// got the semaphore
}
}
// ISR or another task:
fn signaler() {
SEM.release();
}Implementations§
Source§impl<const MAX: u8> Semaphore<MAX>
impl<const MAX: u8> Semaphore<MAX>
Sourcepub fn try_acquire(&self) -> bool
pub fn try_acquire(&self) -> bool
Try to acquire without blocking. Returns true if acquired.
Trait Implementations§
Auto Trait Implementations§
impl<const MAX: u8> !Freeze for Semaphore<MAX>
impl<const MAX: u8> RefUnwindSafe for Semaphore<MAX>
impl<const MAX: u8> Send for Semaphore<MAX>
impl<const MAX: u8> Unpin for Semaphore<MAX>
impl<const MAX: u8> UnsafeUnpin for Semaphore<MAX>
impl<const MAX: u8> UnwindSafe for Semaphore<MAX>
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