Documentation ¶
Overview ¶
Package atomic128 implements atomic operations on 128 bit values. When possible (e.g. on amd64 processors that support CMPXCHG16B), it automatically uses native CPU features to implement the operations; otherwise it falls back to an approach based on mutexes.
Index ¶
- func AddUint128(ptr *Uint128, incr [2]uint64) [2]uint64
- func AndUint128(ptr *Uint128, op [2]uint64) [2]uint64
- func CompareAndSwapUint128(ptr *Uint128, old, new [2]uint64) bool
- func LoadUint128(ptr *Uint128) [2]uint64
- func OrUint128(ptr *Uint128, op [2]uint64) [2]uint64
- func StoreUint128(ptr *Uint128, new [2]uint64)
- func SwapUint128(ptr *Uint128, new [2]uint64) [2]uint64
- func XorUint128(ptr *Uint128, op [2]uint64) [2]uint64
- type Uint128
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddUint128 ¶
AddUint128 atomically adds the incr value to the 128 bit value pointed to by ptr, and it returns the resulting 128 bit value. In the incr and returned values the first of the two elements is the low-order bits.
func AndUint128 ¶ added in v0.2.0
AndUint128 atomically performs a bitwise AND of the op value to the 128 bit value pointed to by ptr, and it returns the resulting 128 bit value. In the op and returned values the first of the two elements is the low-order bits.
func CompareAndSwapUint128 ¶
CompareAndSwapUint128 performs a 128-bit atomic CAS on ptr. If the memory pointed to by ptr contains the value old, it is set to the value new, and true is returned. Otherwise the memory pointed to by ptr is unchanged, and false is returned. In the old and new values the first of the two elements is the low-order bits.
func LoadUint128 ¶
LoadUint128 atomically loads the 128 bit value pointed to by ptr. In the returned value the first of the two elements is the low-order bits.
func OrUint128 ¶ added in v0.2.0
OrUint128 atomically performs a bitwise OR of the op value to the 128 bit value pointed to by ptr, and it returns the resulting 128 bit value. In the op and returned values the first of the two elements is the low-order bits.
func StoreUint128 ¶
StoreUint128 atomically stores the new value in the 128 bit value pointed to by ptr. In the new value the first of the two elements is the low-order bits.
func SwapUint128 ¶
SwapUint128 atomically stores the new value with the 128 bit value pointed to by ptr, and it returns the 128 bit value that was previously pointed to by ptr. In the new and returned values the first of the two elements is the low-order bits.
func XorUint128 ¶ added in v0.2.0
XorUint128 atomically performs a bitwise XOR of the op value to the 128 bit value pointed to by ptr, and it returns the resulting 128 bit value. In the op and returned values the first of the two elements is the low-order bits.