AGX Dynamics  2.37.2.0
StaticData.h File Reference
#include <agx/agx.h>
#include <agx/agxCore_export.h>

Go to the source code of this file.

Classes

class  agx::StaticDataInitializer
 

Namespaces

 agx
 The agx namespace contains the dynamics/math part of the AGX Dynamics API.
 

Macros

#define AGX_STATIC_DATA(_Name, _Type)
 Static data helper to avoid static data initialization order problems (before main). More...
 

Macro Definition Documentation

◆ AGX_STATIC_DATA

#define AGX_STATIC_DATA (   _Name,
  _Type 
)
Value:
static _Type& _Name() \
{ \
static _Type s_instance; \
return s_instance; \
} \
static agx::StaticDataInitializer AGX_CONCAT(__agx_static_data_initializer, _Name)(_Name)
#define AGX_CONCAT(x, y)
Definition: Object.h:40

Static data helper to avoid static data initialization order problems (before main).

Local function member variable is allocated on demand. StaticDataInitializer is used to force initialization before main to avoid potential thread data race conditions. Usage:

AGX_STATIC_DATA(s_var, MyClass); ... s_var().doSomething();

Definition at line 38 of file StaticData.h.