atomic

package
v0.0.0-...-f6902ab Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2023 License: Apache-2.0 Imports: 7 Imported by: 52

Documentation

Index

Constants

View Source
const (
	// True value for atomic.Bool
	True int32 = 1
	// False value for atomic.Bool
	False int32 = 0
)

Variables

This section is empty.

Functions

func BoundsCheck

func BoundsCheck(index int32, length int32, myLength int32)

BoundsCheck is helper function to make sure buffer writes and reads to not go out of bounds on stated buffer capacity

Types

type Bool

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

Bool is an atomic boolean implementation used by aeron-go

func (*Bool) CompareAndSet

func (b *Bool) CompareAndSet(oldVal, newVal bool) bool

CompareAndSet performs an atomic CAS operation on this variable

func (*Bool) Get

func (b *Bool) Get() bool

Get returns the current state of the variable

func (*Bool) Set

func (b *Bool) Set(val bool)

Set atomically sets the value of the variable

type Buffer

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

Buffer is the equivalent of AtomicBuffer used by Aeron Java and C++ implementations. It provides atomic operations on a raw byte buffer wrapped by the structure.

func MakeBuffer

func MakeBuffer(args ...interface{}) *Buffer

MakeBuffer takes a variety of argument options and returns a new atomic.Buffer to the best of its ability

Options for calling
	MakeAtomicBuffer(Pointer)
	MakeAtomicBuffer([]byte)
	MakeAtomicBuffer(Pointer, len)
	MakeAtomicBuffer([]byte, len)

func (*Buffer) Capacity

func (buf *Buffer) Capacity() int32

Capacity of the buffer, which is used for bound checking

func (*Buffer) CompareAndSetInt32

func (buf *Buffer) CompareAndSetInt32(offset int32, expectedValue, updateValue int32) bool

func (*Buffer) CompareAndSetInt64

func (buf *Buffer) CompareAndSetInt64(offset int32, expectedValue, updateValue int64) bool

func (*Buffer) Fill

func (buf *Buffer) Fill(b uint8)

Fill the buffer with the value of the argument byte. Generally used for initialization, since it's somewhat expensive.

func (*Buffer) GetAndAddInt64

func (buf *Buffer) GetAndAddInt64(offset int32, delta int64) int64

func (*Buffer) GetBytes

func (buf *Buffer) GetBytes(offset int32, b []byte)

func (*Buffer) GetBytesArray

func (buf *Buffer) GetBytesArray(offset int32, length int32) []byte

func (*Buffer) GetInt32

func (buf *Buffer) GetInt32(offset int32) int32

func (*Buffer) GetInt32Volatile

func (buf *Buffer) GetInt32Volatile(offset int32) int32

func (*Buffer) GetInt64

func (buf *Buffer) GetInt64(offset int32) int64

func (*Buffer) GetInt64Volatile

func (buf *Buffer) GetInt64Volatile(offset int32) int64

func (*Buffer) GetUInt16

func (buf *Buffer) GetUInt16(offset int32) uint16

func (*Buffer) GetUInt8

func (buf *Buffer) GetUInt8(offset int32) uint8

func (*Buffer) Ptr

func (buf *Buffer) Ptr() unsafe.Pointer

Ptr will return the raw memory pointer for the underlying buffer

func (*Buffer) PutBytes

func (buf *Buffer) PutBytes(index int32, srcBuffer *Buffer, srcint32 int32, length int32)

func (*Buffer) PutBytesArray

func (buf *Buffer) PutBytesArray(index int32, arr *[]byte, srcint32 int32, length int32)

func (*Buffer) PutInt32

func (buf *Buffer) PutInt32(offset int32, value int32)

func (*Buffer) PutInt32Ordered

func (buf *Buffer) PutInt32Ordered(offset int32, value int32)

func (*Buffer) PutInt64

func (buf *Buffer) PutInt64(offset int32, value int64)

func (*Buffer) PutInt64Ordered

func (buf *Buffer) PutInt64Ordered(offset int32, value int64)

func (*Buffer) PutInt8

func (buf *Buffer) PutInt8(offset int32, value int8)

func (*Buffer) PutIntOrdered

func (buf *Buffer) PutIntOrdered(offset int32, value int)

func (*Buffer) PutUInt16

func (buf *Buffer) PutUInt16(offset int32, value uint16)

func (*Buffer) PutUInt8

func (buf *Buffer) PutUInt8(offset int32, value uint8)

func (*Buffer) Wrap

func (buf *Buffer) Wrap(buffer unsafe.Pointer, length int32) *Buffer

Wrap raw memory with this buffer instance

func (*Buffer) WriteBytes

func (buf *Buffer) WriteBytes(dest *bytes.Buffer, offset int32, length int32)

WriteBytes writes data from offset and length to the given dest buffer. This will grow the buffer as needed.

type Int

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

func (*Int) Add

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

func (*Int) Get

func (i *Int) Get() int32

func (*Int) Inc

func (i *Int) Inc() int32

func (*Int) Set

func (i *Int) Set(v int32)

type Long

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

func (*Long) Add

func (i *Long) Add(delta int64) int64

func (*Long) Get

func (i *Long) Get() int64

func (*Long) Inc

func (i *Long) Inc() int64

func (*Long) Set

func (i *Long) Set(v int64)

Jump to

Keyboard shortcuts

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