environment

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Env

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

Env controls goroutines and deferred functions. Think of it as the "main thread." It is not goroutine-safe.

func New

func New() *Env

func (*Env) Close

func (e *Env) Close() error

Close waits for all functions run with Go to finish. Then, it runs all Defer-ed functions. The defered functions are called in reverse order. The Environment must not be used after Close is called.

func (*Env) Defer

func (e *Env) Defer(fn func())

Defer saves fn, which will be run on Close.

func (*Env) DeferErr

func (e *Env) DeferErr(errMsg string, fn func() error)

DeferErr saves fn, which will be run on Close.

func (*Env) Go

func (e *Env) Go(fn func())

Go runs fn in a separate goroutine. Close will block until fn returns.

Jump to

Keyboard shortcuts

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