Page MenuHomePhabricator

D5231.diff
No OneTemporary

D5231.diff

diff --git a/native/cpp/CommonCpp/NativeModules/InternalModules/GlobalDBSingleton.h b/native/cpp/CommonCpp/NativeModules/InternalModules/GlobalDBSingleton.h
new file mode 100644
--- /dev/null
+++ b/native/cpp/CommonCpp/NativeModules/InternalModules/GlobalDBSingleton.h
@@ -0,0 +1,34 @@
+#pragma once
+
+#include "../../Tools/WorkerThread.h"
+
+#include <atomic>
+
+namespace comm {
+class GlobalDBSingleton {
+ std::atomic<bool> multithreadingEnabled;
+ std::unique_ptr<WorkerThread> databaseThread;
+
+ GlobalDBSingleton();
+
+ void scheduleOrRunCommonImpl(const taskType task) {
+ if (this->databaseThread != nullptr) {
+ this->databaseThread->scheduleTask(task);
+ return;
+ }
+ task();
+ }
+
+ void enableMultithreadingCommonImpl() {
+ if (this->databaseThread == nullptr) {
+ this->databaseThread = std::make_unique<WorkerThread>("database");
+ this->multithreadingEnabled.store(true);
+ }
+ }
+
+public:
+ static GlobalDBSingleton instance;
+ void scheduleOrRun(const taskType task);
+ void enableMultithreading();
+};
+} // namespace comm
diff --git a/native/ios/Comm.xcodeproj/project.pbxproj b/native/ios/Comm.xcodeproj/project.pbxproj
--- a/native/ios/Comm.xcodeproj/project.pbxproj
+++ b/native/ios/Comm.xcodeproj/project.pbxproj
@@ -222,6 +222,7 @@
CB38F2BE286C6C980010535C /* DeleteEntryMessageSpec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DeleteEntryMessageSpec.h; path = PersistentStorageUtilities/MessageOperationsUtilities/MessageSpecs/DeleteEntryMessageSpec.h; sourceTree = "<group>"; };
CB38F2BF286C6C980010535C /* UpdateRelationshipMessageSpec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UpdateRelationshipMessageSpec.h; path = PersistentStorageUtilities/MessageOperationsUtilities/MessageSpecs/UpdateRelationshipMessageSpec.h; sourceTree = "<group>"; };
CB3C621327CE66540054F24C /* libEXSecureStore.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libEXSecureStore.a; sourceTree = BUILT_PRODUCTS_DIR; };
+ CBDEC69928ED859600C17588 /* GlobalDBSingleton.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GlobalDBSingleton.h; sourceTree = "<group>"; };
CBFE58272885852B003B94C9 /* ThreadOperations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadOperations.h; path = PersistentStorageUtilities/ThreadOperationsUtilities/ThreadOperations.h; sourceTree = "<group>"; };
CBFE58282885852B003B94C9 /* ThreadOperations.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadOperations.cpp; path = PersistentStorageUtilities/ThreadOperationsUtilities/ThreadOperations.cpp; sourceTree = "<group>"; };
F53DA7B3F26C2798DCE74A94 /* Pods-Comm.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Comm.debug.xcconfig"; path = "Target Support Files/Pods-Comm/Pods-Comm.debug.xcconfig"; sourceTree = "<group>"; };
@@ -467,6 +468,7 @@
726E5D722731A4240032361D /* InternalModules */ = {
isa = PBXGroup;
children = (
+ CBDEC69928ED859600C17588 /* GlobalDBSingleton.h */,
726E5D732731A4790032361D /* NetworkModule.cpp */,
726E5D742731A4790032361D /* NetworkModule.h */,
726E5D762731A5E10032361D /* GlobalNetworkSingleton.cpp */,

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 23, 4:02 PM (19 h, 27 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2571466
Default Alt Text
D5231.diff (3 KB)

Event Timeline