Documentation ¶ Index ¶ type Semaph func NewSemaph(max int32) *Semaph func (s *Semaph) Acquire(ctx context.Context) error func (s *Semaph) Internals() (int32, Stats) func (s *Semaph) Release() type Stats Constants ¶ This section is empty. Variables ¶ This section is empty. Functions ¶ This section is empty. Types ¶ type Semaph ¶ type Semaph struct { // contains filtered or unexported fields } func NewSemaph ¶ func NewSemaph(max int32) *Semaph func (*Semaph) Acquire ¶ func (s *Semaph) Acquire(ctx context.Context) error Acquire will block if there are no more "tickets" left; otherwise will decrement number of tickets and continue. Caller must call Release() later, unless an error is returned, which should always be context.Context.Err(). func (*Semaph) Internals ¶ added in v0.11.0 func (s *Semaph) Internals() (int32, Stats) func (*Semaph) Release ¶ func (s *Semaph) Release() Release will free up a "ticket", and if there were any waiting goroutines, will Signal() (one of) them. type Stats ¶ added in v0.11.0 type Stats struct { Acquired, Waited, Canceled, CanceledDone, WaitDone, WaitCanceled uint64 } Source Files ¶ View all Source files semaph.go Click to show internal directories. Click to hide internal directories.