Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Sema ¶
type Sema struct {
// contains filtered or unexported fields
}
Sema implements semaphore with it can be unlimited by specifying 0
func NewWeighted ¶
NewWeighted creates a new weighted semaphore with the given maximum combined weight for concurrent access. When you specify 0, it means unlimited concurrent access.
func (*Sema) Acquire ¶
Acquire acquires the semaphore with a weight of n, blocking until resources are available or ctx is done. On success, returns nil. On failure, returns ctx.Err() and leaves the semaphore unchanged. If ctx is already done, Acquire may still succeed without blocking. If you created semaphore with 0, this method is non blocking.
Click to show internal directories.
Click to hide internal directories.