diff --git a/native/cpp/CommonCpp/NativeModules/InternalModules/GlobalDBSingletonIOSProxy.h b/native/cpp/CommonCpp/NativeModules/InternalModules/GlobalDBSingletonIOSProxy.h new file mode 100644 --- /dev/null +++ b/native/cpp/CommonCpp/NativeModules/InternalModules/GlobalDBSingletonIOSProxy.h @@ -0,0 +1,11 @@ +#pragma once + +#import "GlobalDBSingleton.h" + +namespace comm { +class GlobalDBSingletonIOSProxy { +public: + static void scheduleOrRun(const taskType task); + static 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 @@ -68,6 +68,7 @@ CB4821B127CFB1FA001AB7E1 /* GlobalNetworkSingleton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 726E5D762731A5E10032361D /* GlobalNetworkSingleton.cpp */; }; CB4821B227CFB20E001AB7E1 /* SQLiteQueryExecutor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 71BE84412636A944002849D2 /* SQLiteQueryExecutor.cpp */; }; CBF332CD28E302EE00E80062 /* GlobalDBSingleton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CBF332CC28E302C600E80062 /* GlobalDBSingleton.cpp */; }; + CBF332D028E3037000E80062 /* GlobalDBSingletonIOSProxy.mm in Sources */ = {isa = PBXBuildFile; fileRef = CBF332CE28E3037000E80062 /* GlobalDBSingletonIOSProxy.mm */; }; CBFE58292885852B003B94C9 /* ThreadOperations.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CBFE58282885852B003B94C9 /* ThreadOperations.cpp */; }; D7DB6E0F85B2DBE15B01EC21 /* libPods-Comm.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 994BEBDD4E4959F69CEA0BC3 /* libPods-Comm.a */; }; F02C296C528B51ADAB5AA19D /* libPods-NotificationService.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3EE4DCB430B05EC9DE7D7B01 /* libPods-NotificationService.a */; }; @@ -223,8 +224,10 @@ CB38F2BE286C6C980010535C /* DeleteEntryMessageSpec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DeleteEntryMessageSpec.h; path = PersistentStorageUtilities/MessageOperationsUtilities/MessageSpecs/DeleteEntryMessageSpec.h; sourceTree = ""; }; CB38F2BF286C6C980010535C /* UpdateRelationshipMessageSpec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UpdateRelationshipMessageSpec.h; path = PersistentStorageUtilities/MessageOperationsUtilities/MessageSpecs/UpdateRelationshipMessageSpec.h; sourceTree = ""; }; CB3C621327CE66540054F24C /* libEXSecureStore.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libEXSecureStore.a; sourceTree = BUILT_PRODUCTS_DIR; }; + CBF32BA128E58AA2005EF313 /* GlobalDBSingletonIOSProxy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GlobalDBSingletonIOSProxy.h; sourceTree = ""; }; CBF332CB28E302C600E80062 /* GlobalDBSingleton.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GlobalDBSingleton.h; sourceTree = ""; }; CBF332CC28E302C600E80062 /* GlobalDBSingleton.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = GlobalDBSingleton.cpp; sourceTree = ""; }; + CBF332CE28E3037000E80062 /* GlobalDBSingletonIOSProxy.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = GlobalDBSingletonIOSProxy.mm; path = Comm/GlobalDBSingletonIOSProxy.mm; sourceTree = ""; }; CBFE58272885852B003B94C9 /* ThreadOperations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadOperations.h; path = PersistentStorageUtilities/ThreadOperationsUtilities/ThreadOperations.h; sourceTree = ""; }; CBFE58282885852B003B94C9 /* ThreadOperations.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadOperations.cpp; path = PersistentStorageUtilities/ThreadOperationsUtilities/ThreadOperations.cpp; sourceTree = ""; }; 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 = ""; }; @@ -331,6 +334,7 @@ 71B8CCB626BD30EC0040C0A2 /* CommCoreImplementations */ = { isa = PBXGroup; children = ( + CBF332CE28E3037000E80062 /* GlobalDBSingletonIOSProxy.mm */, CB38B4782877177B00171182 /* TemporaryMessageStorage */, 71762A74270D8AAE00F565ED /* PlatformSpecificTools.mm */, 71D4D7CB26C50B1000FCDBCD /* CommSecureStore.mm */, @@ -470,6 +474,7 @@ 726E5D722731A4240032361D /* InternalModules */ = { isa = PBXGroup; children = ( + CBF32BA128E58AA2005EF313 /* GlobalDBSingletonIOSProxy.h */, CBF332CC28E302C600E80062 /* GlobalDBSingleton.cpp */, CBF332CB28E302C600E80062 /* GlobalDBSingleton.h */, 726E5D732731A4790032361D /* NetworkModule.cpp */, @@ -1036,6 +1041,7 @@ 71BF5B7126B3FF0900EDE27D /* Session.cpp in Sources */, 726E5D752731A4790032361D /* NetworkModule.cpp in Sources */, 71BF5B7526B401D300EDE27D /* Tools.cpp in Sources */, + CBF332D028E3037000E80062 /* GlobalDBSingletonIOSProxy.mm in Sources */, 13B07FBC1A68108700A75B9A /* AppDelegate.mm in Sources */, 71142A7726C2650B0039DCBD /* CommSecureStoreIOSWrapper.mm in Sources */, FC2DF95528BFCFE90017C4AF /* tunnelbroker.grpc.pb.cc in Sources */, diff --git a/native/ios/Comm/GlobalDBSingletonIOSProxy.mm b/native/ios/Comm/GlobalDBSingletonIOSProxy.mm new file mode 100644 --- /dev/null +++ b/native/ios/Comm/GlobalDBSingletonIOSProxy.mm @@ -0,0 +1,27 @@ +#import "GlobalDBSingletonIOSProxy.h" +#import + +namespace comm { + +void GlobalDBSingletonIOSProxy::scheduleOrRun(const comm::taskType task) { + if (NSThread.isMainThread) { + comm::GlobalDBSingleton::instance.scheduleOrRun(task); + return; + } + + dispatch_async(dispatch_get_main_queue(), ^{ + comm::GlobalDBSingleton::instance.scheduleOrRun(task); + }); +} + +void GlobalDBSingletonIOSProxy::enableMultithreading() { + if (NSThread.isMainThread) { + comm::GlobalDBSingleton::instance.enableMultithreading(); + return; + } + + dispatch_async(dispatch_get_main_queue(), ^{ + comm::GlobalDBSingleton::instance.enableMultithreading(); + }); +} +} // namespace comm