moresync

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2021 License: Apache-2.0, MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Latch

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

A Latch allows one or more routines to wait for the completion of a set of events. After the events are complete, any waiting routines are released, and subsequent invocations of `Wait` return immediately.

It is conceptually similar to a sync.WaitGroup, primary differences being: - the count is set once at construction; - it is not an error for a latch to receive more than the specified `Done` count.

func NewLatch

func NewLatch(count uint) *Latch

NewLatch initializes a new latch with an initial `count`.

func (*Latch) Count

func (latch *Latch) Count() uint

Count returns the latch's current count.

func (*Latch) Done

func (latch *Latch) Done()

Done reduces the latch's count by one, releasing waiting routines if the resulting count is zero. This is a no-op if the count is already zero.

func (*Latch) Wait

func (latch *Latch) Wait()

Wait blocks the calling routine until the count reaches zero.

Jump to

Keyboard shortcuts

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