Skip to main content

Semaphore

Struct Semaphore 

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

A counting semaphore without priority inheritance or task ownership.

up and try_down are IRQ-safe. Blocking acquisition is task-only and grants queued waiters in FIFO order without allowing a new caller to steal a published grant.

Implementations§

Source§

impl Semaphore

Source

pub const fn new(permits: usize) -> Semaphore

Creates a semaphore with permits initially available grants.

Source

pub fn try_down(&self) -> bool

Consumes one available permit without blocking, including in IRQ context.

Source

pub fn up(&self) -> Result<(), SemaphoreError>

Releases a permit or directly grants the oldest queued waiter.

Source

pub fn down(&self) -> Result<(), SemaphoreError>

Waits without interruption until one permit is granted.

Source

pub fn down_interruptible( &self, interrupted: impl FnMut() -> bool, ) -> Result<(), SemaphoreError>

Waits until a permit is granted or an ordinary wake observes interruption. The interruption publisher must also wake this task.

Source

pub fn down_until( &self, deadline: MonotonicDeadline, ) -> Result<(), SemaphoreError>

Waits for a permit until an absolute monotonic deadline.

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

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> Pointee for T

Source§

type Metadata = ()

The metadata type for pointers and references to this type.
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.