pub struct Semaphore { /* private fields */ }Expand description
Semaphore and mutex primitives.
Implementations§
Source§impl Semaphore
impl Semaphore
Sourcepub const fn new_counting(initial: u32, max: u32) -> Self
pub const fn new_counting(initial: u32, max: u32) -> Self
Create a new counting semaphore.
Sourcepub const fn new_mutex(recursive: bool) -> Self
pub const fn new_mutex(recursive: bool) -> Self
Create a new mutex.
If recursive is true, the mutex can be locked multiple times by the same task.
Sourcepub fn take(&self, timeout_us: Option<u32>) -> bool
pub fn take(&self, timeout_us: Option<u32>) -> bool
Take the semaphore.
This is a blocking operation.
If the semaphore is already taken, the task will be blocked until the semaphore is released. Recursive mutexes can be locked multiple times by the mutex owner task.
Sourcepub fn current_count(&self) -> u32
pub fn current_count(&self) -> u32
Return the current count of the semaphore.
Trait Implementations§
Source§impl SemaphoreImplementation for Semaphore
impl SemaphoreImplementation for Semaphore
Source§unsafe fn take(semaphore: SemaphorePtr, timeout_us: Option<u32>) -> bool
unsafe fn take(semaphore: SemaphorePtr, timeout_us: Option<u32>) -> bool
Increments the semaphore’s counter. Read more
Source§unsafe fn current_count(semaphore: SemaphorePtr) -> u32
unsafe fn current_count(semaphore: SemaphorePtr) -> u32
Returns the semaphore’s current counter value. Read more
Source§unsafe fn try_take(semaphore: SemaphorePtr) -> bool
unsafe fn try_take(semaphore: SemaphorePtr) -> bool
Attempts to decrement the semaphore’s counter. Read more
Source§unsafe fn try_give_from_isr(
semaphore: SemaphorePtr,
_hptw: Option<&mut bool>,
) -> bool
unsafe fn try_give_from_isr( semaphore: SemaphorePtr, _hptw: Option<&mut bool>, ) -> bool
Attempts to increment the semaphore’s counter from an ISR. Read more
Source§unsafe fn try_take_from_isr(
semaphore: SemaphorePtr,
_hptw: Option<&mut bool>,
) -> bool
unsafe fn try_take_from_isr( semaphore: SemaphorePtr, _hptw: Option<&mut bool>, ) -> bool
Attempts to decrement the semaphore’s counter from an ISR. Read more