runner

package
v0.0.0-...-5e451f0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Runner

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

Runner is a useful feature for background goroutine life cycle control. It wraps the sync.WaitGroup and provides a channel for receiving the close notify signal. It's used in background go routine loop task as usual. All method are thread-safe and reentrant.

func NewRunner

func NewRunner() *Runner

NewRunner create a Runner object, the typical usage is embed in an object. See testing example for more detail.

func NewRunnerWithContext

func NewRunnerWithContext(ctx context.Context) *Runner

NewRunnerWithContext create a Runner object which could control by context or call CloseWait method.

func (*Runner) CloseWait

func (r *Runner) CloseWait()

CloseWait will stop the runner by close the signal channel and wait for the sync.WaitGroup all Done Synchronously

func (*Runner) Context

func (r *Runner) Context() context.Context

Context return the context of the Runner for controlling by CLoseWait()

func (*Runner) Done

func (r *Runner) Done()

Done is the same as sync.WaitGroup.Done()

func (*Runner) Mark

func (r *Runner) Mark()

Mark is the same as sync.WaitGroup.Add()

func (*Runner) Quit

func (r *Runner) Quit() <-chan struct{}

Quit defines a channel for signal receiving, when the CloseWait is called, this channel will be close

func (*Runner) Wait

func (r *Runner) Wait()

Wait is the same as sync.WaitGroup.Wait()

Jump to

Keyboard shortcuts

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