Struct semaphore::Semaphore
[−]
[src]
pub struct Semaphore { /* fields omitted */ }
An atomic counter which can be shared across processes.
Methods
impl Semaphore
[src]
fn new(limit: usize) -> Self
[src]
Create a new semaphore with the given limit.
fn try_access(&self) -> Option<Guard>
[src]
Attempt to access a resource of this semaphore.
This function will first acquire a resource and then return an RAII guard structure which will release the resource when it falls out of scope.
If the semaphore is at limit, None
will be returned.
fn wait_until_all_released(&self)
[src]
Block until the resource is not being accessed anymore.
This can be used to determine whether it is safe to free or shutdown the resource.