Help us shape the future of Go! Take the 2026 Go Developer Survey

semaph

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 24, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

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
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL