syncs

package
v0.100.0 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2020 License: BSD-3-Clause Imports: 1 Imported by: 60

Documentation

Overview

Package syncs contains addition sync types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClosedChan

func ClosedChan() <-chan struct{}

ClosedChan returns a channel that's already closed.

Types

type AtomicBool added in v0.98.1

type AtomicBool int32

AtomicBool is an atomic boolean.

func (*AtomicBool) Get added in v0.98.1

func (b *AtomicBool) Get() bool

func (*AtomicBool) Set added in v0.98.1

func (b *AtomicBool) Set(v bool)

type WaitGroupChan

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

WaitGroupChan is like a sync.WaitGroup, but has a chan that closes on completion that you can wait on. (This, you can only use the value once) Also, its zero value is not usable. Use the constructor.

func NewWaitGroupChan

func NewWaitGroupChan() *WaitGroupChan

NewWaitGroupChan returns a new single-use WaitGroupChan.

func (*WaitGroupChan) Add

func (c *WaitGroupChan) Add(delta int)

Add adds delta, which may be negative, to the WaitGroupChan counter. If the counter becomes zero, all goroutines blocked on Wait or the Done chan are released. If the counter goes negative, Add panics.

Note that calls with a positive delta that occur when the counter is zero must happen before a Wait. Calls with a negative delta, or calls with a positive delta that start when the counter is greater than zero, may happen at any time. Typically this means the calls to Add should execute before the statement creating the goroutine or other event to be waited for.

func (*WaitGroupChan) Decr

func (wg *WaitGroupChan) Decr()

Decr decrements the WaitGroup counter by one.

(It is like sync.WaitGroup's Done method, but we don't use Done in this type, because it's ambiguous between Context.Done and WaitGroup.Done. So we use DoneChan and Decr instead.)

func (*WaitGroupChan) DoneChan

func (c *WaitGroupChan) DoneChan() <-chan struct{}

DoneChan returns a channel that's closed on completion.

func (*WaitGroupChan) Wait

func (wg *WaitGroupChan) Wait()

Wait blocks until the WaitGroupChan counter is zero.

Jump to

Keyboard shortcuts

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