Struct semka::Sem

source ·
pub struct Sem { /* private fields */ }
Expand description

Windows implementation of Semaphore

Implementations§

source§

impl Sem

source

pub const unsafe fn new_uninit() -> Self

Creates new uninit instance.

It is UB to use it until init is called.

source

pub fn is_init(&self) -> bool

Returns whether semaphore is successfully initialized

source

pub fn init(&self, init: u32) -> bool

Initializes semaphore with provided init as initial value.

Returns true on success.

Returns false if semaphore is already initialized or initialization failed.

source

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

Creates new instance, initializing it with init

source

pub fn wait(&self)

Decrements self, returning immediately if it was signaled.

Otherwise awaits for signal.

source

pub fn try_wait(&self) -> bool

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

Returns true if self was signaled.

Returns false otherwise.

source

pub fn wait_timeout(&self, timeout: Duration) -> bool

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

source

pub fn signal(&self)

Increments self, waking any awaiting thread as result.

source

pub unsafe fn close(&self)

Performs deinitialization.

Using Sem after close is undefined behaviour, unless init is called

Trait Implementations§

source§

impl Drop for Sem

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl Send for Sem

source§

impl Sync for Sem

Auto Trait Implementations§

§

impl RefUnwindSafe for Sem

§

impl Unpin for Sem

§

impl UnwindSafe for Sem

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

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

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

Performs the conversion.
source§

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

§

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.