Documentation ¶
Index ¶
- type AtomicArray
- type AtomicBool
- type AtomicInt
- func (ai *AtomicInt) AddAndGet(delta int) int
- func (ai *AtomicInt) CompareAndSet(expect int, update int) bool
- func (ai *AtomicInt) DecrementAndGet() int
- func (ai *AtomicInt) Get() int
- func (ai *AtomicInt) GetAndAdd(delta int) int
- func (ai *AtomicInt) GetAndDecrement() int
- func (ai *AtomicInt) GetAndIncrement() int
- func (ai *AtomicInt) GetAndSet(newValue int) int
- func (ai *AtomicInt) IncrementAndGet() int
- func (ai *AtomicInt) Set(newValue int)
- type AtomicQueue
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 (*AtomicArray) Get ¶
func (aa *AtomicArray) Get(idx int) interface{}
Atomically Get an element from the Array. If idx is out of range, it will return nil
func (*AtomicArray) Set ¶
func (aa *AtomicArray) Set(idx int, node interface{}) error
Atomically Set an element in the Array. If idx is out of range, it will return an error
type AtomicBool ¶
type AtomicBool struct {
// contains filtered or unexported fields
}
AtomicBool implements a synchronized boolean value
func (*AtomicBool) CompareAndSet ¶
func (ab *AtomicBool) CompareAndSet(expect bool, update bool) bool
Atomically sets the boolean value to updated value, if the current value is as expected.
func (*AtomicBool) GetAndToggle ¶
func (ab *AtomicBool) GetAndToggle() bool
Atomically retrieves the current boolean value first, and then toggles it.
func (*AtomicBool) ToggleAndGet ¶
func (ab *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 (*AtomicInt) CompareAndSet ¶
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 ¶
Atomically decrements current value by one and returns the result
func (*AtomicInt) GetAndAdd ¶
Atomically adds the given delta to the current value and returns the result.
func (*AtomicInt) GetAndDecrement ¶
Atomically decrements the current value by one and returns the result
func (*AtomicInt) GetAndIncrement ¶
Atomically increments current value by one and returns the result.
func (*AtomicInt) GetAndSet ¶
Atomically sets current value to the given value and returns the old value.
func (*AtomicInt) IncrementAndGet ¶
Atomically increments current value by one and returns the result.
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 (aq *AtomicQueue) Offer(item interface{}) bool
Push adds an item to the queue in specified timeout
func (*AtomicQueue) Poll ¶
func (aq *AtomicQueue) Poll() interface{}
Poll removes and returns a node from the queue in first to last order.