sofa-mosn: github.com/sofastack/sofa-mosn/pkg/rcu Index | Files

package rcu

import "github.com/sofastack/sofa-mosn/pkg/rcu"

Index

Package Files

types.go value.go

Variables

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

rcu errors

type Value Uses

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 Uses

func NewValue(i interface{}) *Value

NewValue makes a value with data i

func (*Value) Load Uses

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

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

func (*Value) Put Uses

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 Uses

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

Package rcu imports 4 packages (graph). Updated 2019-11-11. Refresh now. Tools for package owners.