Documentation ¶
Overview ¶
Package semaphores provides a go implementation of binary and counting semaphores. The underlying implementation is built on the channel primitive for goroutine notifications and atomic operations for for the fast path.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Semaphore ¶
type Semaphore interface { // Take (decrement) a semaphore. Routine will block until the semaphore is available. Take() // Take (decrement) a semaphore. Routine will block until the timeout has occurred // or the semaphore becomes available TryTake(timeout time.Duration) bool // Release (increment) the semaphore. Returns false if semaphore is signal. Give() bool // Test if the semaphore is signal. IsFull() bool // Test if the semaphore is empty. IsEmpty() bool // Returns the count of a semaphore. Count() int32 }
Semaphore interface.
func MakeBinarySemaphore ¶
Create a binary semaphore. The semaphore can be initialized to 'up' (signal) or 'down'.
func MakeCountingSemaphore ¶
Create a counting semaphore. The give operation increments the semaphore. A take operation decrements the semaphore.
Click to show internal directories.
Click to hide internal directories.