SemaphoreInterface

Trait SemaphoreInterface 

Source
pub trait SemaphoreInterface: SemaphoreHandle + Debug {
    // Provided methods
    fn post(&self) -> Result<(), SemaphorePostError> { ... }
    fn blocking_wait(&self) -> Result<(), SemaphoreWaitError> { ... }
    fn try_wait(&self) -> Result<bool, SemaphoreWaitError> { ... }
    fn timed_wait(
        &self,
        timeout: Duration,
    ) -> Result<bool, SemaphoreTimedWaitError> { ... }
    fn clock_type(&self) -> ClockType { ... }
}
Expand description

Defines the interface of a NamedSemaphore and an UnnamedSemaphore.

Provided Methods§

Source

fn post(&self) -> Result<(), SemaphorePostError>

Increments the semaphore by one. If the semaphore already holds the maximum supported value another post call will lead to SemaphorePostError::Overflow.

Source

fn blocking_wait(&self) -> Result<(), SemaphoreWaitError>

Decrements the semaphore by one. If the semaphore is zero it waits until a SemaphoreInterface::post() call incremented the semaphore by one. A semaphores internal value is always greater or equal to zero.

Source

fn try_wait(&self) -> Result<bool, SemaphoreWaitError>

Tries to decrement the semaphore by one if it is greater zero and returns true. If the semaphores internal value is zero it returns false and does not decrement the semaphore.

Source

fn timed_wait(&self, timeout: Duration) -> Result<bool, SemaphoreTimedWaitError>

Tries to decrement the semaphore until the decrement was successful and returns true or the timeout has passed and then returns false.

Source

fn clock_type(&self) -> ClockType

Implementors§