rcu

package
v0.0.0-...-78a648b Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Timeout = errors.New("update timeout")
	Block   = errors.New("update is running, try again")
)

rcu errors

Functions

This section is empty.

Types

type Value

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

Value is an rcu value used as rcu lock, have no export fields, can keep any data

func NewValue

func NewValue(i interface{}) *Value

NewValue makes a value with data i

func (*Value) Load

func (v *Value) Load() interface{}

Load returns the keeped data, data used count will add one

func (*Value) Put

func (v *Value) Put(i interface{})

Put the data back, the used count will decrease one If put a data before Load, it will panic

func (*Value) Update

func (v *Value) Update(i interface{}, wait time.Duration) error

Update can update the value directly, but will return success until the data used count is zero or reach timeout If it is reached timeout, it will returns a timeout error with value updated If a Update is not returned, the other Update will be blocked, and returns a block error without value updated

Jump to

Keyboard shortcuts

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