Documentation
¶
Overview ¶
Package semaphore provides an implementation of a counting semaphore.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Semaphore ¶
type Semaphore chan struct{}
Semaphore is a buffered channel based implementation of a counting semaphore.
func (Semaphore) Acquire ¶
Acquire acquires a permit. This call will block until a permit is available or the provided context is completed.
If the provided context is completed, the method will return the cancellation error.
func (Semaphore) TryAcquire ¶
TryAcquire acquires the semaphore without blocking. Returns true if the semaphore is acquired. Otherwise, returns false and leaves the semaphore unchanged.