lock

package
v0.0.0-...-d0e3930 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2021 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MonitorVariable

type MonitorVariable interface {
	Set(value interface{})
	Subscribe() Subscription
}

MonitorVariable is a specific monitor variable which allows for channel-subscription to changes to the internal value of the MonitorVariable.

func NewMonitorVariable

func NewMonitorVariable() MonitorVariable

NewMonitorVariable instantiates an empty monitor variable

type Subscription

type Subscription interface {
	// On instantiation, if the value has been set, this will return a closed channel. Otherwise, it will follow the
	// standard semantic, which is when the Monitor Variable is updated, this channel will close. The channel is updated
	// based on reading Value(). Once a value is read, the channel returned will only be closed if a the Monitor Variable
	// is set to a new value.
	NewValueReady() <-chan struct{}
	// Value returns a value object in a non-blocking fashion. This also means it may return an uninitialized value.
	// If the monitor variable has not yet been set, the "Version" of the value will be 0.
	Value() Value
}

Subscription is not concurrency safe. It must not be shared between multiple goroutines.

type Value

type Value struct {
	Value   interface{}
	Version int64
}

Value contains the last set value from Set(). If the value is unset the version will be 0, and the value will be nil.

Jump to

Keyboard shortcuts

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