sync

package
v0.0.0-...-471d277 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2022 License: Apache-2.0 Imports: 2 Imported by: 1

Documentation

Overview

Package sync contains wrappers around golang's sync wrappers Inspired from https://groups.google.com/forum/#!msg/golang-nuts/QCQkT_sihWY/jMW_pZmmAAAJ

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CountWG

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

CountWG is a counted WaitGroup useful to get the number of items on which we're still waiting for it internally uses sync.WaitGroup and also an int64 counter which is incremented / decremented using sync/atomic package so they're safe for concurrent access

func NewCountWG

func NewCountWG() *CountWG

NewCountWG gives a new version of CountWG to be used

func (*CountWG) Add

func (wg *CountWG) Add(delta int)

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

func (*CountWG) Count

func (wg *CountWG) Count() int

Count returns the counter associated with this CountWG

func (*CountWG) Done

func (wg *CountWG) Done()

Done decrements the CountWG counter.

func (*CountWG) Wait

func (wg *CountWG) Wait()

Wait blocks until the CountWG counter is zero.

Jump to

Keyboard shortcuts

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