libqi-api  2.1.4.13
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Namespaces | Macros | Functions
atomic.hpp File Reference
#include <boost/static_assert.hpp>
#include <qi/config.hpp>
#include <qi/macro.hpp>

Go to the source code of this file.

Classes

struct  qi::AtomicBase< T >
 
class  qi::Atomic< T >
 Atomic operations on integers. More...
 

Namespaces

 qi
 qi general namespace
 

Macros

#define _QI_ATOMIC_HPP_
 
#define _QI_INSTANCIATE(_, a, elem)   ::qi::details::newAndAssign(&elem);
 
#define QI_THREADSAFE_NEW(...)   QI_ONCE(QI_VAARGS_APPLY(_QI_INSTANCIATE, _, __VA_ARGS__);)
 
#define QI_ONCE(code)
 Execute code once, parallel calls are blocked until code finishes. More...
 

Functions

long qi::testAndSet (long *cond)
 

Macro Definition Documentation

#define _QI_ATOMIC_HPP_

Definition at line 10 of file atomic.hpp.

#define _QI_INSTANCIATE (   _,
  a,
  elem 
)    ::qi::details::newAndAssign(&elem);

Definition at line 200 of file atomic.hpp.

#define QI_ONCE (   code)
Value:
static qi::AtomicBase<int> QI_UNIQ_DEF(atomic_guard_a) = {0}; \
static qi::AtomicBase<int> QI_UNIQ_DEF(atomic_guard_b) = {0}; \
while (!QI_UNIQ_DEF(atomic_guard_a).setIfEquals(1, 1)) \
{ \
bool tok = QI_UNIQ_DEF(atomic_guard_b).setIfEquals(0,1); \
if (tok) \
{ \
code; \
++QI_UNIQ_DEF(atomic_guard_a); \
} \
}
#define QI_UNIQ_DEF(A)
Definition: macro.hpp:164

Execute code once, parallel calls are blocked until code finishes.

Definition at line 214 of file atomic.hpp.

#define QI_THREADSAFE_NEW (   ...)    QI_ONCE(QI_VAARGS_APPLY(_QI_INSTANCIATE, _, __VA_ARGS__);)

Accept a list of pointers (expected to be static function variables) and new them once in a thrad-safe manner. Implementation aims for minimal overhead when initialization is done.

Definition at line 210 of file atomic.hpp.