pub trait SemaphoreMethods: SemaphoreHandle {
    fn drain(&self) -> Result<(), DrainSemaphoreError> { ... }
    fn get(&self) -> Result<usize, GetSemaphoreError> { ... }
    fn signal(&self, count: usize) -> Result<(), SignalSemaphoreError> { ... }
    fn signal_one(&self) -> Result<(), SignalSemaphoreError> { ... }
    fn wait_one(&self) -> Result<(), WaitSemaphoreError> { ... }
    fn wait_one_timeout(
        &self,
        timeout: Duration
    ) -> Result<(), WaitSemaphoreTimeoutError> { ... } fn poll_one(&self) -> Result<(), PollSemaphoreError> { ... } }
Expand description

The supported operations on SemaphoreHandle.

Provided Methods

Remove all permits held by the semaphore.

Get the number of permits currently held by the semaphore.

Release count permits, returning them to the semaphore.

Release a permit, returning it to the semaphore.

Acquire a permit, potentially blocking the calling thread until one is available.

This system service may block. Therefore, calling this method is not allowed in a non-waitable context and will return Err(BadContext).

Rationale: Multi-wait (waiting for more than one permit) is not supported because it introduces additional complexity to the wait queue mechanism by requiring it to reevaluate wait conditions after reordering the queue.

The support for multi-wait is relatively rare among operating systems. It’s not supported by POSIX, RTEMS, TOPPERS, VxWorks, nor Win32. The rare exception is μT-Kernel.

wait_one with timeout.

Non-blocking version of wait_one. Returns immediately with PollSemaphoreError::Timeout if the unblocking condition is not satisfied.

Implementors