atomic

package
v0.3.11 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2021 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bool

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

Bool is an atomic Boolean. It stores the bool as a uint32 internally. This is to use the uint32 atomic functions available in golang

func NewBool

func NewBool(initial bool) Bool

NewBool creates a Bool.

func (*Bool) CompareAndSwap

func (b *Bool) CompareAndSwap(old, new bool) bool

CAS is an atomic compare-and-swap.

func (*Bool) Load

func (b *Bool) Load() bool

Load atomically loads the Boolean.

func (*Bool) Store

func (b *Bool) Store(new bool)

Store atomically stores the passed value.

func (*Bool) Swap

func (b *Bool) Swap(new bool) bool

Swap sets the given value and returns the previous value.

func (*Bool) Toggle

func (b *Bool) Toggle() bool

Toggle atomically negates the Boolean and returns the previous value.

type Int32

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

func NewInt32

func NewInt32(v int32) Int32

func (*Int32) Add

func (i *Int32) Add(delta int32) int32

Add a delta to the number

func (*Int32) CompareAndSwap

func (i *Int32) CompareAndSwap(old, new int32) bool

CAS is an atomic compare-and-swap.

func (*Int32) Dec

func (i *Int32) Dec() int32

Decrement the value

func (*Int32) Inc

func (i *Int32) Inc() int32

Increment the value

func (*Int32) Load

func (i *Int32) Load() int32

Returns a loaded uint32 value

func (*Int32) Store

func (i *Int32) Store(v int32)

Set the value

func (*Int32) Sub

func (i *Int32) Sub(delta int32) int32

Subtract a delta from the number

type NonBlockingLock

type NonBlockingLock interface {
	TryLock() bool
	Release()
}

Lock that provides TryLock method instead of blocking lock

func NewNonBlockingLock

func NewNonBlockingLock() NonBlockingLock

type Uint32

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

func NewUint32

func NewUint32(v uint32) Uint32

func (*Uint32) Add

func (u *Uint32) Add(delta uint32) uint32

Add a delta to the number

func (*Uint32) CompareAndSwap

func (u *Uint32) CompareAndSwap(old, new uint32) bool

CAS is an atomic compare-and-swap.

func (*Uint32) Inc

func (u *Uint32) Inc() uint32

Increment the value

func (*Uint32) Load

func (u *Uint32) Load() uint32

Returns a loaded uint32 value

func (*Uint32) Store

func (u *Uint32) Store(v uint32)

Set the value

Jump to

Keyboard shortcuts

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