Help us shape the future of Go! Take the 2026 Go Developer Survey

tmdwg

package module
v0.0.0-...-5a39540 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2018 License: MIT Imports: 3 Imported by: 0

README

Build Status Coverage Status Go Report Card GoDoc Donate

Timed WaitGroup for Go

tmdwg-go provides a timed wait group implementation similar to sync.WaitGroup.

It's purpose is simple: it blocks all goroutines that called it's wg.Wait() method and frees them when:

  • either the timeout is reached...
  • or the progress is reached

In case the timeout was reached before the progress wg.Wait() will return a timeout error, otherwise it'll return nil.

The timed wait group is fully thread safe and may safely be used concurrently from within multiple goroutines.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TimedWaitGroup

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

TimedWaitGroup represents a WaitGroup

func NewTimedWaitGroup

func NewTimedWaitGroup(target int, timeout time.Duration) *TimedWaitGroup

NewTimedWaitGroup constructs a new timed wait group and starts the timeout counter. Target and timeout arguments must both be bigger 0

func (*TimedWaitGroup) CurrentProgress

func (p *TimedWaitGroup) CurrentProgress() int

CurrentProgress returns the current progress

func (*TimedWaitGroup) IsCompleted

func (p *TimedWaitGroup) IsCompleted() bool

IsCompleted returns true if the wait group already completed, otherwise returns false

func (*TimedWaitGroup) Progress

func (p *TimedWaitGroup) Progress(delta int) int

Progress progresses the wait group by the given delta. Returns the current progress after the update

func (*TimedWaitGroup) Wait

func (p *TimedWaitGroup) Wait() error

Wait blocks until the wait group is either completed or timed out. Returns an error if the wait group timed out

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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