concurrency

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Group

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

Group manages concurrency groups with semaphores

func NewGroup

func NewGroup() *Group

NewGroup creates a new concurrency group manager

func (*Group) Acquire

func (g *Group) Acquire(ctx context.Context, name string, maxParallel int) error

Acquire acquires a slot in the named concurrency group maxParallel defines how many can run in parallel (0 = unlimited)

func (*Group) Release

func (g *Group) Release(name string)

Release releases a slot in the named concurrency group

type Semaphore

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

Semaphore is a counting semaphore for limiting concurrency

func NewSemaphore

func NewSemaphore(n int) *Semaphore

NewSemaphore creates a new semaphore with the given capacity

func (*Semaphore) Acquire

func (s *Semaphore) Acquire(ctx context.Context) error

Acquire acquires a slot, blocking until one is available or context is cancelled

func (*Semaphore) Available

func (s *Semaphore) Available() int

Available returns the number of available slots

func (*Semaphore) Capacity

func (s *Semaphore) Capacity() int

Capacity returns the total capacity

func (*Semaphore) Release

func (s *Semaphore) Release()

Release releases a slot

func (*Semaphore) TryAcquire

func (s *Semaphore) TryAcquire() bool

TryAcquire attempts to acquire a slot without blocking Returns true if acquired, false otherwise

Jump to

Keyboard shortcuts

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