concurrent

package
v2.3.2 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2023 License: Apache-2.0 Imports: 3 Imported by: 7

Documentation

Overview

Package concurrent provides common functionality for dealing with concurrency that extends or enhances the core golang packages.

Deprecated: concurrent is no longer planned to be used by future WebPA/XMiDT services.

This package is frozen and no new functionality will be added.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Await

func Await(runnable Runnable, signals <-chan os.Signal) error

Await uses Execute() to invoke a runnable, then waits for any traffic on a signal channel before shutting down gracefully.

func Execute

func Execute(runnable Runnable) (waitGroup *sync.WaitGroup, shutdown chan struct{}, err error)

Execute is a convenience function that creates the necessary synchronization objects and then invokes Run().

func WaitTimeout

func WaitTimeout(waitGroup *sync.WaitGroup, timeout time.Duration) bool

WaitTimeout performs a timed wait on a given sync.WaitGroup

Types

type Runnable

type Runnable interface {
	// Run executes this operation, possibly returning an error if the operation
	// could not be started.  This method is responsible for spawning any necessary
	// goroutines and to ensure WaitGroup.Add() and WaitGroup.Done() are called appropriately.
	// Generally speaking, Run() should be idempotent.
	//
	// The supplied shutdown channel is used to signal any goroutines spawned by this
	// method that they should gracefully exit.  Callers can then use the waitGroup to
	// wait until things have been cleaned up properly.
	Run(waitGroup *sync.WaitGroup, shutdown <-chan struct{}) error
}

Runnable represents any operation that can spawn zero or more goroutines.

type RunnableFunc

type RunnableFunc func(*sync.WaitGroup, <-chan struct{}) error

RunnableFunc is a function type that implements Runnable

func (RunnableFunc) Run

func (r RunnableFunc) Run(waitGroup *sync.WaitGroup, shutdown <-chan struct{}) error

type RunnableSet

type RunnableSet []Runnable

RunnableSet is a slice type that allows grouping of operations. This type implements Runnable as well.

func (RunnableSet) Run

func (set RunnableSet) Run(waitGroup *sync.WaitGroup, shutdown <-chan struct{}) error

Jump to

Keyboard shortcuts

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