Semaphore

Struct Semaphore 

Source
pub struct Semaphore { /* private fields */ }
Expand description

Semaphore and mutex primitives.

Implementations§

Source§

impl Semaphore

Source

pub const fn new_counting(initial: u32, max: u32) -> Self

Create a new counting semaphore.

Source

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.

Source

pub fn try_take(&self) -> bool

Try to take the semaphore.

This is a non-blocking operation.

Source

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.

Source

pub fn current_count(&self) -> u32

Return the current count of the semaphore.

Source

pub fn give(&self) -> bool

Unlock the semaphore.

Trait Implementations§

Source§

impl SemaphoreImplementation for Semaphore

Available on crate feature esp-radio only.
Source§

fn create(kind: SemaphoreKind) -> SemaphorePtr

Creates a new semaphore instance. Read more
Source§

unsafe fn delete(semaphore: SemaphorePtr)

Deletes a semaphore instance. Read more
Source§

unsafe fn take(semaphore: SemaphorePtr, timeout_us: Option<u32>) -> bool

Increments the semaphore’s counter. Read more
Source§

unsafe fn give(semaphore: SemaphorePtr) -> bool

Increments the semaphore’s counter. Read more
Source§

unsafe fn current_count(semaphore: SemaphorePtr) -> u32

Returns the semaphore’s current counter value. Read more
Source§

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

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

Attempts to decrement the semaphore’s counter from an ISR. Read more

Auto Trait Implementations§

§

impl !Freeze for Semaphore

§

impl !RefUnwindSafe for Semaphore

§

impl !Send for Semaphore

§

impl !Sync for Semaphore

§

impl Unpin for Semaphore

§

impl !UnwindSafe for Semaphore

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.