ezEngine  Milestone 7
ezAtomicUtils Struct Reference

This class provides functions to do atomic operations. More...

#include <AtomicUtils.h>

Static Public Member Functions

static ezInt32 Read (volatile const ezInt32 &src)
 Returns src as an atomic operation and returns its value.
 
static ezInt64 Read (volatile const ezInt64 &src)
 Returns src as an atomic operation and returns its value.
 
static ezInt32 Increment (volatile ezInt32 &dest)
 Increments dest as an atomic operation and returns the new value.
 
static ezInt64 Increment (volatile ezInt64 &dest)
 Increments dest as an atomic operation and returns the new value.
 
static ezInt32 Decrement (volatile ezInt32 &dest)
 Decrements dest as an atomic operation and returns the new value.
 
static ezInt64 Decrement (volatile ezInt64 &dest)
 Decrements dest as an atomic operation and returns the new value.
 
static void Add (volatile ezInt32 &dest, ezInt32 value)
 Adds value to dest as an atomic operation.
 
static void Add (volatile ezInt64 &dest, ezInt64 value)
 Adds value to dest as an atomic operation.
 
static void And (volatile ezInt32 &dest, ezInt32 value)
 Performs an atomic bitwise AND on dest using value.
 
static void And (volatile ezInt64 &dest, ezInt64 value)
 Performs an atomic bitwise AND on dest using value.
 
static void Or (volatile ezInt32 &dest, ezInt32 value)
 Performs an atomic bitwise OR on dest using value.
 
static void Or (volatile ezInt64 &dest, ezInt64 value)
 Performs an atomic bitwise OR on dest using value.
 
static void Xor (volatile ezInt32 &dest, ezInt32 value)
 Performs an atomic bitwise XOR on dest using value.
 
static void Xor (volatile ezInt64 &dest, ezInt64 value)
 Performs an atomic bitwise XOR on dest using value.
 
static void Min (volatile ezInt32 &dest, ezInt32 value)
 Performs an atomic min operation on dest using value.
 
static void Min (volatile ezInt64 &dest, ezInt64 value)
 Performs an atomic min operation on dest using value.
 
static void Max (volatile ezInt32 &dest, ezInt32 value)
 Performs an atomic max operation on dest using value.
 
static void Max (volatile ezInt64 &dest, ezInt64 value)
 Performs an atomic max operation on dest using value.
 
static ezInt32 Set (volatile ezInt32 &dest, ezInt32 value)
 Sets dest to value as an atomic operation and returns the original value of dest.
 
static ezInt64 Set (volatile ezInt64 &dest, ezInt64 value)
 Sets dest to value as an atomic operation and returns the original value of dest.
 
static bool TestAndSet (volatile ezInt32 &dest, ezInt32 expected, ezInt32 value)
 Sets dest to value if dest is equal to expected and returns true, otherwise does nothing and returns false.
 
static bool TestAndSet (volatile ezInt64 &dest, ezInt64 expected, ezInt64 value)
 Sets dest to value if dest is equal to expected and returns true, otherwise does nothing and returns false.
 
static bool TestAndSet (void **volatile dest, void *expected, void *value)
 Sets dest to value if dest is equal to expected and returns true, otherwise does nothing and returns false.
 

Detailed Description

This class provides functions to do atomic operations.

Atomic operations are generally faster than mutexes, and should therefore be preferred whenever possible. However only the operations in themselves are atomic, once you execute several of them in sequence, the sequence will not be atomic. Also atomic operations are a lot slower than non-atomic operations, thus you should not use them in code that does not need to be thread-safe. ezAtomicInteger is built on top of ezAtomicUtils and provides a more convenient interface to use atomic integer instructions.


The documentation for this struct was generated from the following files: