[−][src]Struct fe_osi::semaphore::Semaphore
A tool used to prevent data races.
Implementations
impl Semaphore
[src]
pub const fn new(start_count: usize) -> Semaphore
[src]
Creates a Semaphore with a specified starting count.
pub const fn new_mutex() -> Semaphore
[src]
Creates a mutex Semaphore. Usually used for locking
pub fn is_available(&self) -> bool
[src]
Returns true if the Semaphore can be taken, false otherwise.
pub fn take(&self)
[src]
Takes a Semaphore for a task. If the Semaphore cannot be taken right away, block until it can be taken.
pub fn try_take(&self) -> bool
[src]
Attempt to take the Semaphore. If the Semaphore is taken, return true. Otherwise, return false.
pub fn give(&self)
[src]
In a mutex Semaphore, give() sets the count to 1. In a non-mutex Semaphore, gives increments the count by 1.
pub fn with_lock<F: FnMut()>(&self, f: F)
[src]
Takes the Semaphore, executes the closure, then gives the Semaphore.
pub fn try_with_lock<F: FnMut()>(&self, f: F) -> bool
[src]
Attempts to take the Semaphore. If it succeeds, execute the closure, return true, then give back the Semaphore. Otherwise, it will return false.
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,