barrier

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package barrier coordinates participants with epoch isolation and bounds.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrClosed    = errors.New("barrier: closed")
	ErrFull      = errors.New("barrier: participant bound exceeded")
	ErrEpoch     = errors.New("barrier: epoch mismatch")
	ErrDuplicate = errors.New("barrier: duplicate participant")
	ErrPolicy    = errors.New("barrier: policy not satisfied")
)

Functions

This section is empty.

Types

type Barrier

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

Barrier is an epoch-scoped rendezvous.

func New

func New(cfg Config) (*Barrier, error)

New creates a Barrier.

func (*Barrier) Arrive

func (b *Barrier) Arrive(participantID string, epoch uint64) error

Arrive registers participant identity for this epoch and may release waiters.

func (*Barrier) Close

func (b *Barrier) Close() error

Close fails the barrier and wakes waiters.

func (*Barrier) Count

func (b *Barrier) Count() int

Count returns current participants.

func (*Barrier) Released

func (b *Barrier) Released() bool

Released reports whether the barrier has released.

func (*Barrier) Wait

func (b *Barrier) Wait(ctx context.Context) error

Wait blocks until the policy is satisfied or ctx ends.

type Config

type Config struct {
	Name            string
	Epoch           uint64
	MaxParticipants int // hard bound; required > 0
	Policy          Policy
	MinimumCount    int // for minimum-count
	Clock           func() time.Time
}

Config configures a Barrier.

type Policy

type Policy string

Policy selects release conditions.

const (
	PolicyMinimumCount Policy = "minimum-count"
	PolicyQuorum       Policy = "quorum" // majority of MaxParticipants
	PolicyExact        Policy = "exact"
	PolicyAll          Policy = "all" // == MaxParticipants
)

Jump to

Keyboard shortcuts

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