atomic

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2014 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AtomicArray

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

AtomicArray implement a fixed width array with atomic semantics

func NewAtomicArray

func NewAtomicArray(length int) *AtomicArray

Generator for AtomicArray

func (*AtomicArray) Get

func (this *AtomicArray) Get(idx int) AtomicArrayItem

Atomically Get an element from the Array. If idx is out of range, it will return nil

func (*AtomicArray) Length

func (this *AtomicArray) Length() int

Get array size.

func (*AtomicArray) Set

func (this *AtomicArray) Set(idx int, node AtomicArrayItem) error

Atomically Set an element in the Array. If idx is out of range, it will return an error

type AtomicArrayItem

type AtomicArrayItem interface{}

type AtomicBool

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

AtomicBool implements a synchronized boolean value

func NewAtomicBool

func NewAtomicBool(value bool) *AtomicBool

Generator for AtomicBoolean

func (*AtomicBool) CompareAndSet

func (this *AtomicBool) CompareAndSet(expect bool, update bool) bool

Atomically sets the boolean value to updated value, if the current value is as expected.

func (*AtomicBool) Get

func (this *AtomicBool) Get() bool

Atomically retrieves the boolean value.

func (*AtomicBool) GetAndToggle

func (this *AtomicBool) GetAndToggle() bool

Atomically retrieves the current boolean value first, and then toggles it.

func (*AtomicBool) Set

func (this *AtomicBool) Set(newVal bool)

Atomically sets the boolean value.

func (*AtomicBool) ToggleAndGet

func (this *AtomicBool) ToggleAndGet() bool

Atomically toggles the boolean value first, and then retrieves it.

type AtomicInt

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

AtomicInt implements an int value with atomic semantics

func NewAtomicInt

func NewAtomicInt(value int) *AtomicInt

Generator for AtomicInt

func (*AtomicInt) AddAndGet

func (ai *AtomicInt) AddAndGet(delta int) int

Atomically adds the given value to the current value.

func (*AtomicInt) CompareAndSet

func (ai *AtomicInt) CompareAndSet(expect int, update int) bool

Atomically sets the value to the given updated value if the current value == the expected value. Returns true if the expectation was met

func (*AtomicInt) DecrementAndGet

func (ai *AtomicInt) DecrementAndGet() int

Atomically decrements current value by one and returns the result

func (*AtomicInt) Get

func (ai *AtomicInt) Get() int

Gets the current ai.value.

func (*AtomicInt) GetAndAdd

func (ai *AtomicInt) GetAndAdd(delta int) int

Atomically adds the given delta to the current value and returns the result.

func (*AtomicInt) GetAndDecrement

func (ai *AtomicInt) GetAndDecrement() int

Atomically decrements the current value by one and returns the result

func (*AtomicInt) GetAndIncrement

func (ai *AtomicInt) GetAndIncrement() int

Atomically increments current value by one and returns the result.

func (*AtomicInt) GetAndSet

func (ai *AtomicInt) GetAndSet(newValue int) int

Atomically sets current value to the given value and returns the old value.

func (*AtomicInt) IncrementAndGet

func (ai *AtomicInt) IncrementAndGet() int

Atomically increments current value by one and returns the result.

func (*AtomicInt) Set

func (ai *AtomicInt) Set(newValue int)

Sets current value to the given value.

type AtomicQueue

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

AtomicQueue is a blocking FIFO queue If the queue is empty, nil is returned. if the queue is full, offer will return false

func NewAtomicQueue

func NewAtomicQueue(size int) *AtomicQueue

NewQueue creates a new queue with initial size

func (*AtomicQueue) Offer

func (this *AtomicQueue) Offer(item interface{}) bool

Push adds an item to the queue in specified timeout

func (*AtomicQueue) Poll

func (this *AtomicQueue) Poll() interface{}

Pop removes and returns a node from the queue in first to last order.

Jump to

Keyboard shortcuts

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