semaphore

package
v0.0.0-...-b5ba5ed Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: MPL-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MultiSemaphore

type MultiSemaphore []*Semaphore

MultiSemaphore combines semaphores, making sure to always take and give in the same order (reversed for give). A semaphore may be nil, in which case it is skipped.

func (MultiSemaphore) Give

func (s MultiSemaphore) Give(size int)

func (MultiSemaphore) Take

func (s MultiSemaphore) Take(size int)

func (MultiSemaphore) TakeWithContext

func (s MultiSemaphore) TakeWithContext(ctx context.Context, size int) error

type Semaphore

type Semaphore struct {
	// contains filtered or unexported fields
}

func New

func New(max int) *Semaphore

func (*Semaphore) Available

func (s *Semaphore) Available() int

func (*Semaphore) Give

func (s *Semaphore) Give(size int)

func (*Semaphore) SetCapacity

func (s *Semaphore) SetCapacity(capacity int)

func (*Semaphore) Take

func (s *Semaphore) Take(size int)

func (*Semaphore) TakeWithContext

func (s *Semaphore) TakeWithContext(ctx context.Context, size int) error

Jump to

Keyboard shortcuts

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