versioned

package
v0.3.13 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Versioned

type Versioned[T any] struct {
	Val T
	// contains filtered or unexported fields
}

Versioned[T] is a linearizable register storing a value of type T. Each update to the value changes its unique (but not necessarily ordered) version. Spurious version changes are possible, i.e., the version may change even if the value hasn't.

Like a sync.Mutex, Versioned should not be copied.

func Version

func Version[T any](val T) *Versioned[T]

func (*Versioned[T]) Lock

func (v *Versioned[T]) Lock()

Lock acquires the write lock.

func (*Versioned[T]) RLock

func (v *Versioned[T]) RLock(version string) string

RLock waits until the current version is different than the passed-in version, and then acquires the read lock and returns the new version.

func (*Versioned[T]) RUnlock

func (v *Versioned[T]) RUnlock()

RUnlock releases the read lock.

func (*Versioned[T]) Unlock

func (v *Versioned[T]) Unlock()

Unlock releases the write lock.

Jump to

Keyboard shortcuts

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