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 */; }; @@ -225,6 +226,8 @@ CB3C621327CE66540054F24C /* libEXSecureStore.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libEXSecureStore.a; sourceTree = BUILT_PRODUCTS_DIR; }; 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 = ""; }; + CBF332CF28E3037000E80062 /* GlobalDBSingletonIOSProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GlobalDBSingletonIOSProxy.h; path = Comm/GlobalDBSingletonIOSProxy.h; 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,8 @@ 71B8CCB626BD30EC0040C0A2 /* CommCoreImplementations */ = { isa = PBXGroup; children = ( + CBF332CF28E3037000E80062 /* GlobalDBSingletonIOSProxy.h */, + CBF332CE28E3037000E80062 /* GlobalDBSingletonIOSProxy.mm */, CB38B4782877177B00171182 /* TemporaryMessageStorage */, 71762A74270D8AAE00F565ED /* PlatformSpecificTools.mm */, 71D4D7CB26C50B1000FCDBCD /* CommSecureStore.mm */, @@ -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.h b/native/ios/Comm/GlobalDBSingletonIOSProxy.h new file mode 100644 --- /dev/null +++ b/native/ios/Comm/GlobalDBSingletonIOSProxy.h @@ -0,0 +1,10 @@ +#pragma once + +#import "GlobalDBSingleton.h" + +#import + +@interface GlobalDBSingletonIOSProxy : NSObject ++ (void)scheduleOrRun:(const comm::taskType)task; ++ (void)enableMultithreading; +@end 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,28 @@ +#import "GlobalDBSingletonIOSProxy.h" +#import "Logger.h" + +@implementation GlobalDBSingletonIOSProxy + ++ (void)scheduleOrRun:(const comm::taskType)task { + + if (NSThread.isMainThread) { + comm::GlobalDBSingleton::instance.scheduleOrRun(task); + return; + } + + dispatch_sync(dispatch_get_main_queue(), ^{ + comm::GlobalDBSingleton::instance.scheduleOrRun(task); + }); +} + ++ (void)enableMultithreading { + if (NSThread.isMainThread) { + comm::GlobalDBSingleton::instance.enableMultithreading(); + return; + } + + dispatch_sync(dispatch_get_main_queue(), ^{ + comm::GlobalDBSingleton::instance.enableMultithreading(); + }); +} +@end