package semaphore
Import Path
golang.org/x/sync/semaphore (on go.dev)
Dependency Relation
imports 3 packages, and imported by one package
Involved Source Files
Package semaphore provides a weighted semaphore implementation.
Package-Level Type Names (total 2, in which 1 is exported)
Weighted provides a way to bound concurrent access to a resource.
The callers can request access with a given weight.
cur int64
mu sync.Mutex
size int64
waiters list.List
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.
Release releases the semaphore with a weight of n.
TryAcquire acquires the semaphore with a weight of n without blocking.
On success, returns true. On failure, returns false and leaves the semaphore unchanged.
(*Weighted) notifyWaiters()
func NewWeighted(n int64) *Weighted
func github.com/jackc/puddle/v2.acquireSemAll(sem *Weighted, num int) int
Package-Level Functions (only one, which is exported)
NewWeighted creates a new weighted semaphore with the given
maximum combined weight for concurrent access.
The pages are generated with Golds v0.7.6. (GOOS=linux GOARCH=amd64)