Trait SemaphoreImpl

Source
pub trait SemaphoreImpl: Sync {
    // Required methods
    fn increment(&self);
    fn decrement(&self);
}
Expand description

A trait to implement a semaphore object.

Required Methods§

Source

fn increment(&self)

Increments the semaphore.

Source

fn decrement(&self)

Decrements the semaphore, possible waiting for an increment if the internal counter is already at zero.

Single-threaded platforms can implement this as a no-op, so this might never wait. Any functionality making use of this function should make sure to check that any resource being synchronized with this semaphore is actually in the expected state, and panic or otherwise error out if it’s not.

Implementors§