versioned

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2023 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 added in v0.2.0

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 added in v0.2.0

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

func (*Versioned[T]) Lock added in v0.2.0

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

Lock acquires the write lock.

func (*Versioned[T]) RLock added in v0.2.0

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 added in v0.2.0

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

RUnlock releases the read lock.

func (*Versioned[T]) Unlock added in v0.2.0

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