libqi-api
2.0.6.8
|
Go to the source code of this file.
Classes | |
struct | qi::AtomicBase< T > |
class | qi::Atomic< T > |
Atomic operations on integers. More... | |
Namespaces | |
namespace | qi |
qi general namespace | |
Defines | |
#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. | |
Functions | |
long | qi::testAndSet (long *cond) |
#define _QI_INSTANCIATE | ( | _, | |
a, | |||
elem | |||
) | ::qi::details::newAndAssign(&elem); |
Definition at line 200 of file atomic.hpp.
#define QI_ONCE | ( | code | ) |
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); \ } \ }
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.