Struct semka::Sem[][src]

pub struct Sem { /* fields omitted */ }
Expand description

POSIX implementation of Semaphore

Implementations

impl Sem[src]

pub const unsafe fn new_uninit() -> Self[src]

Creates new uninit instance.

It is UB to use it until init is called.

#[must_use]
pub fn init(&self, init: u32) -> bool
[src]

Initializes semaphore with provided init as initial value.

Returns true on success.

Returns false if semaphore is already initialized or initialization failed.

pub fn new(init: u32) -> Option<Self>[src]

Creates new instance, initializing it with init

pub fn wait(&self)[src]

Decrements self, returning immediately if it was signaled.

Otherwise awaits for signal.

pub fn try_wait(&self) -> bool[src]

Attempts to decrement self, returning whether self was signaled or not.

Returns true if self was signaled.

Returns false otherwise.

pub fn wait_timeout(&self, duration: Duration) -> bool[src]

Attempts to decrement self within provided time, returning whether self was signaled or not.

Returns true if self was signaled within specified timeout

Returns false otherwise

pub fn signal(&self)[src]

Increments self, waking any awaiting thread as result.

Trait Implementations

impl Drop for Sem[src]

fn drop(&mut self)[src]

Executes the destructor for this type. Read more

impl Send for Sem[src]

impl Sync for Sem[src]

Auto Trait Implementations

impl Unpin for Sem

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.