pub struct Semaphore { /* private fields */ }Expand description
A counting or binary semaphore
Implementations§
Source§impl Semaphore
impl Semaphore
Sourcepub fn new_binary() -> Result<Semaphore, FreeRtosError>
pub fn new_binary() -> Result<Semaphore, FreeRtosError>
Create a new binary semaphore
Sourcepub unsafe fn from_raw_handle(handle: FreeRtosSemaphoreHandle) -> Self
pub unsafe fn from_raw_handle(handle: FreeRtosSemaphoreHandle) -> Self
§Safety
handle must be a valid FreeRTOS semaphore handle.
Only binary or counting semaphore is expected here.
To create mutex from raw handle use crate::mutex::MutexInnerImpl::from_raw_handle.
pub fn raw_handle(&self) -> FreeRtosSemaphoreHandle
Sourcepub fn lock<D: DurationTicks>(
&self,
max_wait: D,
) -> Result<SemaphoreGuard<'_>, FreeRtosError>
pub fn lock<D: DurationTicks>( &self, max_wait: D, ) -> Result<SemaphoreGuard<'_>, FreeRtosError>
Lock this semaphore in a RAII fashion
Sourcepub fn give(&self) -> bool
pub fn give(&self) -> bool
Returns true on success, false when semaphore count already reached its limit
pub fn take<D: DurationTicks>(&self, max_wait: D) -> Result<(), FreeRtosError>
Sourcepub fn give_from_isr(&self, context: &mut InterruptContext) -> bool
pub fn give_from_isr(&self, context: &mut InterruptContext) -> bool
Returns true on success, false when semaphore count already reached its limit
Sourcepub fn take_from_isr(&self, context: &mut InterruptContext) -> bool
pub fn take_from_isr(&self, context: &mut InterruptContext) -> bool
Returns true on success, false if the semaphore was not successfully taken because it was not available
Trait Implementations§
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