neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
i_shared_thread_local.hpp File Reference

Go to the source code of this file.

Classes

class  neolib::i_shared_thread_local
 Shared thread local service. More...
 
struct  neolib::i_shared_thread_local::result_type
 

Namespaces

namespace  neolib
 

Macros

#define shared_thread_local_impl(VariableType, VariableScope, VariableName, InitialValue)
 
#define shared_thread_local_class_impl(VariableType, ClassType, VariableScope, VariableName, InitialValue)
 
#define shared_thread_local(VariableType, VariableScope, VariableName, ...)    shared_thread_local_impl(VariableType, VariableScope, VariableName, __VA_ARGS__)
 
#define shared_thread_local_class(VariableType, ClassType, VariableScope, VariableName, ...)    shared_thread_local_class_impl(VariableType, ClassType, VariableScope, VariableName, __VA_ARGS__)
 

Macro Definition Documentation

◆ shared_thread_local

#define shared_thread_local (   VariableType,
  VariableScope,
  VariableName,
  ... 
)     shared_thread_local_impl(VariableType, VariableScope, VariableName, __VA_ARGS__)

Definition at line 101 of file i_shared_thread_local.hpp.

◆ shared_thread_local_class

#define shared_thread_local_class (   VariableType,
  ClassType,
  VariableScope,
  VariableName,
  ... 
)     shared_thread_local_class_impl(VariableType, ClassType, VariableScope, VariableName, __VA_ARGS__)

Definition at line 104 of file i_shared_thread_local.hpp.

◆ shared_thread_local_class_impl

#define shared_thread_local_class_impl (   VariableType,
  ClassType,
  VariableScope,
  VariableName,
  InitialValue 
)
Value:
thread_local auto const neolib_PartialResult_##VariableName = \
neolib::service<neolib::i_shared_thread_local>().allocate_or_get<VariableType>( \
(std::string{ typeid(ClassType).name() } + "::" STRING(VariableScope) "::" STRING(VariableName)).c_str(), \
[](void* aMemory) { using neolib_VariableTypeAlias = VariableType; static_cast<VariableType*>(aMemory)->~neolib_VariableTypeAlias(); }); \
auto const& neolib_CapturablePartialResult_##VariableName = neolib_PartialResult_##VariableName; \
thread_local auto& VariableName = [&neolib_CapturablePartialResult_##VariableName]() -> VariableType& \
{ \
if (neolib_CapturablePartialResult_##VariableName.initializationRequired) \
{ \
new (static_cast<VariableType*>(neolib_CapturablePartialResult_##VariableName.memory)) VariableType{ InitialValue }; \
} \
return *static_cast<VariableType*>(neolib_CapturablePartialResult_##VariableName.memory); \
}();
#define STRING(x)
Definition neolib.hpp:57

Definition at line 86 of file i_shared_thread_local.hpp.

◆ shared_thread_local_impl

#define shared_thread_local_impl (   VariableType,
  VariableScope,
  VariableName,
  InitialValue 
)
Value:
thread_local auto const neolib_PartialResult_##VariableName = \
neolib::service<neolib::i_shared_thread_local>().allocate_or_get<VariableType>( \
STRING(VariableScope) "::" STRING(VariableName), \
[](void* aMemory) { using VariableTypeAlias = VariableType; static_cast<VariableType*>(aMemory)->~VariableTypeAlias(); }); \
auto const& neolib_CapturablePartialResult_##VariableName = neolib_PartialResult_##VariableName; \
thread_local auto& VariableName = [&neolib_CapturablePartialResult_##VariableName]() -> VariableType& \
{ \
if (neolib_CapturablePartialResult_##VariableName.initializationRequired) \
{ \
new (static_cast<VariableType*>(neolib_CapturablePartialResult_##VariableName.memory)) VariableType{ InitialValue }; \
} \
return *static_cast<VariableType*>(neolib_CapturablePartialResult_##VariableName.memory); \
}();

Definition at line 71 of file i_shared_thread_local.hpp.