flux

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2022 License: BSD-3-Clause Imports: 1 Imported by: 1

Documentation

Overview

Package flux provides concurrently accessible scalar value types which can be updated incrementally. A single observer goroutine can receive change notifications via a channel. There can be one or more mutator goroutines.

Mutator goroutines can call the Increment, Poke, Finish and Value methods. The consumer goroutine can call the Chan and Value methods.

There isn't a one-to-one correspondence between updates and notifications: multiple Increment calls may be coalesced to a single successful channel reception. It's also possible that the same value is observed after receiving a notification. The value may wrap around; it's the application's responsibility to take that into account.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Uint32

type Uint32 struct {
	Waker
	// contains filtered or unexported fields
}

Uint32 value in flux.

func MakeUint32

func MakeUint32(initial uint32) Uint32

MakeUint32 is for initializing a field. Multiple copies of the struct value must not be used.

func NewUint32

func NewUint32(initial uint32) *Uint32

NewUint32 value in flux.

func (*Uint32) Increment

func (x *Uint32) Increment(i uint32)

Increment the value and possibly notify the observer. The value may wrap around.

func (*Uint32) Value

func (x *Uint32) Value() uint32

Value takes a snapshot. The value may have wrapped around (multiple times) since previous call.

type Uint64

type Uint64 struct {
	Waker
	// contains filtered or unexported fields
}

Uint64 value in flux.

func MakeUint64

func MakeUint64(initial uint64) Uint64

MakeUint64 is for initializing a field. Multiple copies of the struct value must not be used.

func NewUint64

func NewUint64(initial uint64) *Uint64

NewUint64 value in flux.

func (*Uint64) Increment

func (x *Uint64) Increment(i uint64)

Increment the value and possibly notify the observer. The value may wrap around.

func (*Uint64) Value

func (x *Uint64) Value() uint64

Value takes a snapshot. The value may have wrapped around (multiple times) since previous call.

type Waker

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

Waker coalesces notifications.

func MakeWaker

func MakeWaker() Waker

MakeWaker for a single outstanding notification.

func (Waker) Chan

func (w Waker) Chan() <-chan struct{}

Chan is unblocked when it's time to wake up. It is closed at Finish.

func (Waker) Finish

func (w Waker) Finish()

Finish wakes up the observer for the last time. Chan will be closed.

func (Waker) Poke

func (w Waker) Poke()

Poke the observer to wake it up, unless a wake-up is already pending.

Jump to

Keyboard shortcuts

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