MCPcopy
hub / github.com/cortexlabs/cortex / newSemaphore

Function newSemaphore

pkg/proxy/breaker.go:182–187  ·  view source on GitHub ↗

newSemaphore creates a semaphore with the desired initial capacity.

(maxCapacity, initialCapacity int)

Source from the content-addressed store, hash-verified

180
181// newSemaphore creates a semaphore with the desired initial capacity.
182func newSemaphore(maxCapacity, initialCapacity int) *semaphore {
183 queue := make(chan struct{}, maxCapacity)
184 sem := &semaphore{queue: queue}
185 sem.updateCapacity(initialCapacity)
186 return sem
187}
188
189// semaphore is an implementation of a semaphore based on packed integers and a channel.
190// state is an uint64 that has two uint32s packed into it: capacity and inFlight. The

Calls 1

updateCapacityMethod · 0.95