nbl

package
v0.0.0-...-168ccc2 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2021 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package nbl provides various non-blocking algorithms.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Int64

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

Int64 implements int64 value for one writer and multiple readers. It is designed for architectures that does not support 64-bit atomic operations.

func (*Int64) ABA

func (i *Int64) ABA() uintptr

func (*Int64) CheckABA

func (i *Int64) CheckABA(aba uintptr) (uintptr, bool)

func (*Int64) Load

func (i *Int64) Load() int64

Load uses ABA, TryLoad and CheckABA to load and return value of i.

BUG: On 32bit CPUs Load does not guarantee that it returns valid value. The probability of failure depends on the frequency of updates: 1 kHz: aba wraps onece per 1193 houres, 1 MHz: aba wraps once per 72 minutes. Load fails if aba wraps beetwen ABA and CheckABA or between subsequent CheckABA and after that is readed second time with the same value.

func (*Int64) TryLoad

func (i *Int64) TryLoad(aba uintptr) int64

func (*Int64) WriterAdd

func (i *Int64) WriterAdd(v int64) int64

WriterAdd performs i += v and returns new value of i. Only ONE writer can call WriterAdd at the same time.

func (*Int64) WriterLoad

func (i *Int64) WriterLoad() int64

WriterLoad is more efficient than Load but there should be guarantee that only one writer can write to i at the same time.

func (*Int64) WriterStore

func (i *Int64) WriterStore(v int64)

WriterStore stores v into i. Only ONE writer can call WriterStore at the same time.

Jump to

Keyboard shortcuts

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