state

package
v0.12.0-beta4 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package state provides state tracking facilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Marker added in v0.12.0

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

Marker is a utility type used to track if a condition has occurred. It is safe for concurrent usage and designed for usage on hot paths. The zero value of Marker is unmarked.

func (*Marker) Mark added in v0.12.0

func (m *Marker) Mark()

Mark idempotently marks the marker.

func (*Marker) Marked added in v0.12.0

func (m *Marker) Marked() bool

Marked returns whether or not the marker is marked.

type Tracker

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

Tracker provides index-based state tracking using a condition variable.

func NewTracker

func NewTracker() *Tracker

NewTracker creates a new tracker instance with state index 1.

func (*Tracker) NotifyOfChange

func (t *Tracker) NotifyOfChange()

NotifyOfChange indicates the state index and notifies waiters.

func (*Tracker) Poison

func (t *Tracker) Poison()

Poison terminates tracking.

func (*Tracker) WaitForChange

func (t *Tracker) WaitForChange(previousIndex uint64) (uint64, bool)

WaitForChange waits for a state index change from the previous index.

type TrackingLock

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

TrackingLock provides locking facilities with automatic state tracking notifications.

func NewTrackingLock

func NewTrackingLock(tracker *Tracker) *TrackingLock

NewTrackingLock creates a new tracking lock with the specified tracker.

func (*TrackingLock) Lock

func (l *TrackingLock) Lock()

Lock locks the tracking lock.

func (*TrackingLock) Unlock

func (l *TrackingLock) Unlock()

Unlock unlocks the tracking lock and triggers a state update notification.

func (*TrackingLock) UnlockWithoutNotify

func (l *TrackingLock) UnlockWithoutNotify()

UnlockWithoutNotify unlocks the tracking lock without triggering a state update notification.

Jump to

Keyboard shortcuts

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