[][src]Struct fe_osi::semaphore::Semaphore

#[repr(C)]pub struct Semaphore { /* fields omitted */ }

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

impl Send for Semaphore

impl Sync for Semaphore

impl Unpin for Semaphore

Blanket Implementations

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

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

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

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

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

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.

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.