goro

package
v1.12.4 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2021 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 Handle

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

Handle is a threadsafe and multi-stop safe handle to a running goroutine.

func Go

func Go(ctx context.Context, f func(context.Context) error) *Handle

Go launches the supplied function in its own goroutine and returns back a *Handle that serves as a handle to the goroutine itself.

func (*Handle) Cancel

func (h *Handle) Cancel()

Cancel requests that this goroutine stop by cancelling the associated context object. This function is threadsafe and idempotent. Note that this function _requests_ termination, it does not forcefully kill the goroutine.

func (*Handle) Done

func (h *Handle) Done() <-chan struct{}

Done exposes a channel that allows outside goroutines to block on this goroutine's completion. Whatever time passes between a call to Cancel() and the Done() channel closing is the time taken by the goroutine to shut itself down.

func (*Handle) Err

func (h *Handle) Err() error

Error observes the error returned by the func passed to Go (if any). There is nevery any error (i.e. this function returns nil) while the goroutine is running.

Jump to

Keyboard shortcuts

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