atomicx

package
v3.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2021 License: BSD-3-Clause Imports: 1 Imported by: 0

README

Package github.com/ooni/probe-engine/atomicx

Atomic int64/float64 that works also on 32 bit platforms.

Documentation

Overview

Package atomicx contains atomic int64/float64 that work also on 32 bit platforms. The main reason for rolling out this package is to avoid potential crashes when using 32 bit devices where we are atomically accessing a 64 bit variable that is not aligned. The solution to this issue is rather crude: use a normal variable and protect it using a normal mutex. While this could be disappointing in general, it seems fine to be done in our context where we mainly use atomic semantics for counting.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Float64

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

Float64 is an float64 with atomic semantics.

func NewFloat64

func NewFloat64() *Float64

NewFloat64 creates a new float64 with atomic semantics.

func (*Float64) Add

func (f64 *Float64) Add(delta float64) (newvalue float64)

Add behaves like AtomicInt64.Add but for float64

func (*Float64) Load

func (f64 *Float64) Load() (v float64)

Load behaves like LoadInt64.Load buf for float64

type Int64

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

Int64 is an int64 with atomic semantics.

func NewInt64

func NewInt64() *Int64

NewInt64 creates a new int64 with atomic semantics.

func (*Int64) Add

func (i64 *Int64) Add(delta int64) (newvalue int64)

Add behaves like atomic.AddInt64

func (*Int64) Load

func (i64 *Int64) Load() (v int64)

Load behaves like atomic.LoadInt64

Jump to

Keyboard shortcuts

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