semaphore

package
v0.0.0-...-3e0e934 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: Apache-2.0, BSD-2-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package semaphore provides a weighted semaphore implementation. ref: https://github.com/golang/go/issues/29721

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Limiter

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

func NewLimiter

func NewLimiter(limit int64) *Limiter

func (*Limiter) Acquire

func (l *Limiter) Acquire(ctx context.Context) error

func (*Limiter) Current

func (l *Limiter) Current() int64

func (*Limiter) Limit

func (l *Limiter) Limit() int64

func (*Limiter) Peak

func (l *Limiter) Peak() int64

func (*Limiter) Release

func (l *Limiter) Release()

func (*Limiter) SetLimit

func (l *Limiter) SetLimit(limit int64)

func (*Limiter) TryAcquire

func (l *Limiter) TryAcquire() (success bool)

type Weighted

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

func NewWeighted

func NewWeighted(n int64) *Weighted

func (*Weighted) Acquire

func (s *Weighted) Acquire(ctx context.Context, n int64) error

func (*Weighted) GetCurrent

func (s *Weighted) GetCurrent() int64

func (*Weighted) Release

func (s *Weighted) Release(n int64)

func (*Weighted) Resize

func (s *Weighted) Resize(n int64)

func (*Weighted) Size

func (s *Weighted) Size() int64

func (*Weighted) TryAcquire

func (s *Weighted) TryAcquire(n int64) (int64, bool)

Jump to

Keyboard shortcuts

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