Skip to content

Latest commit

 

History

History
115 lines (63 loc) · 2.3 KB

File metadata and controls

115 lines (63 loc) · 2.3 KB

barrier

import "github.com/andy2046/gopie/pkg/barrier"

Package barrier provides a barrier implementation.

barrier.go

var (
    // ErrBroken when barrier is broken.
    ErrBroken = errors.New("barrier is broken")
)
type Barrier struct {
    // contains filtered or unexported fields
}

Barrier is a synchronizer that allows members to wait for each other.

func New(n int) *Barrier

New returns a new barrier.

func (*Barrier) Await

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

Await waits until all members have called await on the barrier.

func (*Barrier) IsBroken

func (b *Barrier) IsBroken() bool

IsBroken returns true if the barrier is broken.

func (*Barrier) N

func (b *Barrier) N() int

N returns the number of members for the barrier.

func (*Barrier) NWaiting

func (b *Barrier) NWaiting() int

NWaiting returns the number of members currently waiting at the barrier.

func (*Barrier) Reset

func (b *Barrier) Reset()

Reset resets the barrier to initial state.


Generated by godoc2md