rcu2: github.com/as/rcu2 Index | Files | Directories

package rcu2

import "github.com/as/rcu2"

Index

Package Files

rcu.go

type Dir Uses

type Dir struct {
    File unsafe.Pointer // *File
}

func (*Dir) Del Uses

func (d *Dir) Del(key string) (v Value, ok bool)

Del deletes the named key. It returns non-nil v if the value existed and was successfully deleted. It returns !ok if a concurrent write occured.

Most callers should just check the value of ok

func (*Dir) Get Uses

func (d *Dir) Get(key string) (v Value)

Get returns the value for the key. Ok is true if the key exists.

func (*Dir) Keys Uses

func (d *Dir) Keys(names ...string) []string

Key returns a list of key names

func (*Dir) Swap Uses

func (d *Dir) Swap(f *File, key string, val Value) bool

Swap stores the key and value in f. If key already exists in f, the swap operation is O(1), otherwise, it's O(len(f)) due to RCU.

Swap returns false if a concurrent modification occured during the call.

type File Uses

type File struct {
    Map   map[string]int // maps names to index in Value
    Value []Value
    Name  []string // Names in []Value
}

func (*File) Add Uses

func (f *File) Add(key string, v Value) *File

func (*File) Del Uses

func (f *File) Del(key string) *File

func (*File) Get Uses

func (f *File) Get(key string) Value

type Store Uses

type Store struct {
    Dir
}

func New Uses

func New() *Store

New returns an initialized Store

func (*Store) Del Uses

func (s *Store) Del(path, key string) (Value, bool)

Del deletes the path's key value. It returns true if the value does not exist after the call completed (this could mean the value never existed).

It returns false if and only if a concurrent modification prevented the operation from ascertaining that the key no longer exists.

func (*Store) Get Uses

func (s *Store) Get(path, key string) (v Value)

Get returns the path's key value. Ok is false if it does not exist.

func (*Store) Keys Uses

func (s *Store) Keys(path ...string) []string

Keys returns the names of the keys which exist under the given list of paths. If len(path)==0, the list of keys for all existing paths is returned

func (*Store) Put Uses

func (s *Store) Put(path, key string, val Value) bool

Put associates the value with the path's key. It returns false if a concurrent modification prevented the call from completing the Put.

TODO(as): Algorithm complexity

type Value Uses

type Value interface{}

Directories

PathSynopsis
example

Package rcu2 imports 2 packages (graph) and is imported by 1 packages. Updated 2018-12-15. Refresh now. Tools for package owners.