Struct semaphore::Semaphore [] [src]

pub struct Semaphore<T> { /* fields omitted */ }

Counting semaphore to control concurrent access to a common resource.

Methods

impl<T> Semaphore<T>
[src]

[src]

Create a new semaphore around a resource.

The semaphore will limit the number of processes that can access the underlying resource at every point in time to the specified capacity.

[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 out of capacity or shut down, a TryAccessError will be returned.

[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.

Trait Implementations

impl<T> Clone for Semaphore<T>
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more