pkgsync

package
v0.0.0-...-15a92f0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2016 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrAlreadyDestroyed is the error returned when a function is called
	// on a Destroyable that has already been destroyed.
	ErrAlreadyDestroyed = errors.New("pkgsync: already destroyed")
)

Functions

This section is empty.

Types

type Destroyable

type Destroyable interface {
	Destroy() error
	Do(func() (interface{}, error)) (interface{}, error)
}

Destroyable is a wrapper for any object that allows an atomic destroy operation to be performed, and will monitor if other functions are called after the object has already been destroyed.

func NewDestroyable

func NewDestroyable() Destroyable

NewDestroyable creates a new Destroyable.

type LazyLoader

type LazyLoader interface {
	Load() (interface{}, error)
}

LazyLoader allows a function to be lazily atomically loaded.

func NewLazyLoader

func NewLazyLoader(f func() (interface{}, error)) LazyLoader

NewLazyLoader creates a new LazyLoader.

type VolatileBool

type VolatileBool interface {
	// Get the current value.
	Value() bool
	// Set the value to newBool, and return oldBool == newBool.
	CompareAndSwap(oldBool bool, newBool bool) bool
}

VolatileBool is a volatile bool.

TODO(pedge): Is this even needed? Need to understand go memory model better.

func NewVolatileBool

func NewVolatileBool(initialBool bool) VolatileBool

NewVolatileBool creates a new VolatileBool.

Jump to

Keyboard shortcuts

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