Honeycomb  0.1
Component-Model Framework
Classes | Typedefs | Enumerations
honey::atomic Namespace Reference

Atomic operations. More...

Classes

class  Op
 Methods to perform thread-safe atomic read/write operations. More...
 
struct  SwapType
 Get the smallest atomically-swappable type that is large enough to hold T. More...
 

Typedefs

typedef platform::SwapMaxType SwapMaxType
 Largest atomically-swappable type. More...
 

Enumerations

enum  Order {
  Order::relaxed, Order::consume, Order::acquire, Order::release,
  Order::acqRel, Order::seqCst
}
 Atomic memory order for concurrent synchronization between threads. More...
 

Detailed Description

Atomic operations.

Typedef Documentation

typedef platform::SwapMaxType honey::atomic::SwapMaxType

Largest atomically-swappable type.

Enumeration Type Documentation

enum honey::atomic::Order
strong

Atomic memory order for concurrent synchronization between threads.

Compilers and hardware optimize ops assuming the environment is single-threaded, this causes race conditions in a concurrent environment.
The safest but slowest order is sequential consistency, load/store ops will not be optimized and thus will be executed in the order as written.
The fastest but unsafest order is relaxed, load/store ops can be fully optimized and thus re-ordered.
Release and acquire pairs provide a middle ground that allows some re-ordering.
A release on an atomic in thread 1 will synchronize with an acquire on that same atomic in thread 2.
Synchronization guarantees that all operations before the release in thread 1 will be executed before the acquire in thread 2.

See also
std::memory_order for details.
Enumerator
relaxed 

No order constraint, same as plain load/store. Unsafe but best performance.

consume 

Must be a load op. Synchronize with a prior release in another thread, but only synchronize ops dependent on this load.

acquire 

Must be a load op. Synchronize with a prior release in another thread.

release 

Must be a store op. Synchronize with a later acquire in another thread.

acqRel 

Must be a load-modify-store op. Performs both acquire and release.

seqCst 

Sequential consistency, safe total order but least performance.