#define WRT_ENGINE_SRC_CONFIGURATION_WEBRUNTIME_DATABASE_H
#include <dpl/thread.h>
-#include <dpl/mutex.h>
-
-extern DPL::Mutex g_wrtDbQueriesMutex;
-
-#define WRT_DB_INTERNAL(tlsCommand, InternalType, interface) \
- static DPL::ThreadLocalVariable<InternalType> *tlsCommand##Ptr = NULL; \
- { \
- DPL::Mutex::ScopedLock lock(&g_wrtDbQueriesMutex); \
- if (!tlsCommand##Ptr) { \
- static DPL::ThreadLocalVariable<InternalType> tmp; \
- tlsCommand##Ptr = &tmp; \
- } \
- } \
- DPL::ThreadLocalVariable<InternalType> &tlsCommand = *tlsCommand##Ptr; \
- if (tlsCommand.IsNull()) { tlsCommand = InternalType(interface); }
-
-#define WRT_DB_SELECT(name, type, interface) WRT_DB_INTERNAL(name, \
- type::Select, \
+#include <mutex>
+
+extern std::mutex g_wrtDbQueriesMutex;
+
+#define WRT_DB_INTERNAL(tlsCommand, InternalType, interface) \
+ static DPL::ThreadLocalVariable<InternalType> *tlsCommand##Ptr = NULL; \
+ { \
+ std::lock_guard<std::mutex> lock(g_wrtDbQueriesMutex); \
+ if (!tlsCommand##Ptr) { \
+ static DPL::ThreadLocalVariable<InternalType> tmp; \
+ tlsCommand##Ptr = &tmp; \
+ } \
+ } \
+ DPL::ThreadLocalVariable<InternalType> &tlsCommand = *tlsCommand##Ptr; \
+ if (!tlsCommand) { tlsCommand = InternalType(interface); }
+
+#define WRT_DB_SELECT(name, type, interface) WRT_DB_INTERNAL(name, \
+ type::Select, \
interface)
-#define WRT_DB_INSERT(name, type, interface) WRT_DB_INTERNAL(name, \
- type::Insert, \
+#define WRT_DB_INSERT(name, type, interface) WRT_DB_INTERNAL(name, \
+ type::Insert, \
interface)
-#define WRT_DB_UPDATE(name, type, interface) WRT_DB_INTERNAL(name, \
- type::Update, \
+#define WRT_DB_UPDATE(name, type, interface) WRT_DB_INTERNAL(name, \
+ type::Update, \
interface)
-#define WRT_DB_DELETE(name, type, interface) WRT_DB_INTERNAL(name, \
- type::Delete, \
+#define WRT_DB_DELETE(name, type, interface) WRT_DB_INTERNAL(name, \
+ type::Delete, \
interface)
#endif // WRT_ENGINE_SRC_CONFIGURATION_WEBRUNTIME_DATABASE_H