Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Semaphore ¶
type Semaphore struct {
// contains filtered or unexported fields
}
Semaphore represents a custom semaphore with optional capacity.
func NewSemaphore ¶
NewSemaphore creates and initializes a new Semaphore with the specified initial capacity.
func (*Semaphore) Acquire ¶
Acquire acquires n units from the semaphore if the capacity is not unlimited.
func (*Semaphore) Release ¶
Release releases n units back to the semaphore if the capacity is not unlimited.
func (*Semaphore) Resize ¶
Resize adjusts the maximum capacity of the semaphore. Acquires or releases permits accordingly.
func (*Semaphore) TryAcquire ¶
TryAcquire attempts to acquire n units from the semaphore without blocking if the capacity is not unlimited.
Click to show internal directories.
Click to hide internal directories.