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 non-negative weight.
cur int64
mu sync.Mutex
size int64
waiters list.List
Acquire acquires the semaphore with a non-negative 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 non-negative weight of n.
TryAcquire acquires the semaphore with a non-negative 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. NewWeighted panics if n is
negative.
The pages are generated with Golds v0.8.7. (GOOS=linux GOARCH=amd64)