safe

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Go

func Go(goroutine func())

Go starts a recoverable goroutine

func GoWithRecover

func GoWithRecover(goroutine func(), customRecover func(err interface{}))

GoWithRecover starts a recoverable goroutine using given customRecover() function

func OperationWithRecover

func OperationWithRecover(operation backoff.Operation) backoff.Operation

OperationWithRecover wrap a backoff operation in a Recover

Types

type Pool

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

Pool is a pool of go routines

func NewPool

func NewPool(parentCtx context.Context) *Pool

NewPool creates a Pool

func (*Pool) AddGoCtx

func (p *Pool) AddGoCtx(goroutine routineCtx)

AddGoCtx adds a recoverable goroutine with a context without starting it

func (*Pool) Cleanup

func (p *Pool) Cleanup()

Cleanup releases resources used by the pool, and should be called when the pool will no longer be used

func (*Pool) Ctx

func (p *Pool) Ctx() context.Context

Ctx returns main context

func (*Pool) Go

func (p *Pool) Go(goroutine func(stop chan bool))

Go starts a recoverable goroutine, and can be stopped with stop chan

func (*Pool) GoCtx

func (p *Pool) GoCtx(goroutine routineCtx)

GoCtx starts a recoverable goroutine with a context

func (*Pool) Start

func (p *Pool) Start()

Start starts all stopped routines

func (*Pool) Stop

func (p *Pool) Stop()

Stop stops all started routines, waiting for their termination

type Safe

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

Safe contains a thread-safe value

func New

func New(value interface{}) *Safe

New create a new Safe instance given a value

func (*Safe) Get

func (s *Safe) Get() interface{}

Get returns the value

func (*Safe) Set

func (s *Safe) Set(value interface{})

Set sets a new value

Jump to

Keyboard shortcuts

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