rcu

package module
v0.0.0-...-5069028 Latest Latest
Warning

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

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

README

rcu

Simple non-kernel-assisted (a.k.a userland) RCU library in Go.

Implementing RCU on garbage collected languages is actually quite simpler than usual as we do not need to handle quiescent states (the garbage collector handles that for us). So all we need is make atomic swaps so everything is neatly lock-less but still thread-safe.

More on RCU can be read here.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Data

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

Data represents a thread-safe lock-free RCU value. The zero value is valid and represents a Data[T] with a nil value pointer.

func NewData

func NewData[T any](value *T) Data[T]

NewData returns a new Data[T] associated with the given value.

func (*Data[T]) GetValue

func (d *Data[T]) GetValue() *T

GetValue returns the current value pointer associated with Data[T].

func (*Data[T]) SetIfNilValue

func (d *Data[T]) SetIfNilValue(value *T) bool

SetIfNilValue sets the value pointer associated with Data[T] to the given value iff the current value pointer is nil. Returns true if the value was set and false otherwise.

func (*Data[T]) SetValue

func (d *Data[T]) SetValue(value *T)

SetValue sets the value pointer associated with Data[T] to the given one.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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