Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3396485
D5576.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D5576.diff
View Options
diff --git a/native/android/app/src/cpp/GlobalDBSingleton.cpp b/native/android/app/src/cpp/GlobalDBSingleton.cpp
--- a/native/android/app/src/cpp/GlobalDBSingleton.cpp
+++ b/native/android/app/src/cpp/GlobalDBSingleton.cpp
@@ -6,7 +6,8 @@
GlobalDBSingleton::GlobalDBSingleton()
: multithreadingEnabled(true),
- databaseThread(std::make_unique<WorkerThread>("database")) {
+ databaseThread(std::make_unique<WorkerThread>("database")),
+ tasksCancelled(false) {
}
void GlobalDBSingleton::scheduleOrRun(const taskType task) {
diff --git a/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp b/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp
--- a/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp
+++ b/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp
@@ -1062,7 +1062,8 @@
jsi::Value CommCoreModule::clearSensitiveData(jsi::Runtime &rt) {
return createPromiseAsJSIValue(
rt, [this](jsi::Runtime &innerRt, std::shared_ptr<Promise> promise) {
- GlobalDBSingleton::instance.scheduleOrRun([this, promise]() {
+ GlobalDBSingleton::instance.setTasksCancelled(true);
+ taskType job = [this, promise]() {
std::string error;
try {
DatabaseManager::getQueryExecutor().clearSensitiveData();
@@ -1076,7 +1077,10 @@
promise->resolve(jsi::Value::undefined());
}
});
- });
+ GlobalDBSingleton::instance.scheduleOrRun(
+ []() { GlobalDBSingleton::instance.setTasksCancelled(false); });
+ };
+ GlobalDBSingleton::instance.scheduleOrRun(job);
});
}
diff --git a/native/cpp/CommonCpp/NativeModules/InternalModules/GlobalDBSingleton.h b/native/cpp/CommonCpp/NativeModules/InternalModules/GlobalDBSingleton.h
--- a/native/cpp/CommonCpp/NativeModules/InternalModules/GlobalDBSingleton.h
+++ b/native/cpp/CommonCpp/NativeModules/InternalModules/GlobalDBSingleton.h
@@ -8,6 +8,7 @@
class GlobalDBSingleton {
std::atomic<bool> multithreadingEnabled;
std::unique_ptr<WorkerThread> databaseThread;
+ std::atomic<bool> tasksCancelled;
GlobalDBSingleton();
@@ -30,5 +31,8 @@
static GlobalDBSingleton instance;
void scheduleOrRun(const taskType task);
void enableMultithreading();
+ void setTasksCancelled(bool tasksCancelled) {
+ this->tasksCancelled.store(tasksCancelled);
+ }
};
} // namespace comm
diff --git a/native/ios/Comm/GlobalDBSingleton.mm b/native/ios/Comm/GlobalDBSingleton.mm
--- a/native/ios/Comm/GlobalDBSingleton.mm
+++ b/native/ios/Comm/GlobalDBSingleton.mm
@@ -5,7 +5,9 @@
GlobalDBSingleton GlobalDBSingleton::instance;
GlobalDBSingleton::GlobalDBSingleton()
- : multithreadingEnabled(false), databaseThread(nullptr) {
+ : multithreadingEnabled(false),
+ databaseThread(nullptr),
+ tasksCancelled(false) {
}
void GlobalDBSingleton::scheduleOrRun(const taskType task) {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Dec 2, 12:47 PM (22 h, 8 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2607619
Default Alt Text
D5576.diff (2 KB)
Attached To
Mode
D5576: [native] introduce atomic flag that indicates clearing database process will execute
Attached
Detach File
Event Timeline
Log In to Comment