pub struct Sem { /* private fields */ }
Expand description
POSIX implementation of Semaphore
Implementations§
source§impl Sem
impl Sem
sourcepub const unsafe fn new_uninit() -> Self
pub const unsafe fn new_uninit() -> Self
Creates new uninit instance.
It is UB to use it until init
is called.
sourcepub fn init(&self, init: u32) -> bool
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.
sourcepub fn wait(&self)
pub fn wait(&self)
Decrements self, returning immediately if it was signaled.
Otherwise awaits for signal.
sourcepub fn try_wait(&self) -> bool
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.
sourcepub fn wait_timeout(&self, duration: Duration) -> bool
pub fn wait_timeout(&self, duration: 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
Trait Implementations§
Auto Trait Implementations§
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more