Struct semaphore::Semaphore
[−]
[src]
pub struct Semaphore<T> { /* fields omitted */ }
An atomic counter which can be shared across processes.
Methods
impl<T> Semaphore<T>
[src]
fn new(limit: usize, resource: T) -> Self
[src]
Create a new semaphore with the given limit.
fn try_access(&self) -> Result<Guard<T>, TryAccessError>
[src]
Attempt to access the underlying resource of this semaphore.
This function will try to acquire access, and then return an RAII guard structure which will release the access when it falls out of scope.
If the semaphore is at limit or currently shutting down,
a TryAccessError
will be returned.
fn shutdown(&self) -> ShutdownHandle<T>
[src]
Shut down the semaphore.
This prevents any further access from being granted to the underlying resource.
As soon as the last access is released and the returned handle goes out of scope, the resource will be dropped.
Does not block until the resource is no longer in use. If you would like to do that,
you can call wait
on the returned handle.