Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Sema ¶
type Sema chan struct{}
Sema provides a simple semaphore implementation using a channel
func New ¶
New creates a new semaphore with the given maximum capacity for concurrent access. Will panic if cap < 1
func (Sema) Acquire ¶
func (s Sema) Acquire()
Acquire the semaphore, will block if semaphore is full until any other holder release it. Will panic if semaphore is nil
func (Sema) AcquireWithin ¶
AcquireWithin the given timeout return true on success and false on failure Will panic if semaphore is nil
func (Sema) Release ¶
func (s Sema) Release()
Release the semaphore Will panic if called on a non acquired semaphore
func (Sema) TryAcquire ¶
TryAcquire the semaphore without blocking return true on success and false on failure. Will panic if semaphore is nil
Click to show internal directories.
Click to hide internal directories.