mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Synchronize access to LongLivedObjectCollection instances (#43450)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/43450 Changelog: [Internal] This is just to make sure that all instances of `LongLivedObjectCollection` map can be safely accessed by multiple threads. Reviewed By: RSNara Differential Revision: D54801015 fbshipit-source-id: e0b15bfbeac9ce3a1051f83a59c5513a90ba2a4b
This commit is contained in:
committed by
Facebook GitHub Bot
parent
eef87ca59e
commit
41b6371940
@@ -16,6 +16,9 @@ LongLivedObjectCollection& LongLivedObjectCollection::get(
|
||||
jsi::Runtime& runtime) {
|
||||
static std::unordered_map<void*, std::shared_ptr<LongLivedObjectCollection>>
|
||||
instances;
|
||||
static std::mutex instancesMutex;
|
||||
|
||||
std::scoped_lock lock(instancesMutex);
|
||||
void* key = static_cast<void*>(&runtime);
|
||||
auto entry = instances.find(key);
|
||||
if (entry == instances.end()) {
|
||||
|
||||
Reference in New Issue
Block a user