Improve thread safety of ReactNativeFeatureFlags#42870
Conversation
|
This pull request was exported from Phabricator. Differential Revision: D53406924 |
739f2f1 to
9cdde53
Compare
|
This pull request was exported from Phabricator. Differential Revision: D53406924 |
Base commit: f3977af |
9cdde53 to
a20e6bf
Compare
|
This pull request was exported from Phabricator. Differential Revision: D53406924 |
a20e6bf to
641b002
Compare
|
This pull request was exported from Phabricator. Differential Revision: D53406924 |
641b002 to
2a09a6a
Compare
|
This pull request was exported from Phabricator. Differential Revision: D53406924 |
2a09a6a to
8a7f427
Compare
|
This pull request was exported from Phabricator. Differential Revision: D53406924 |
8a7f427 to
d0a8ea3
Compare
|
This pull request was exported from Phabricator. Differential Revision: D53406924 |
d0a8ea3 to
abe44a1
Compare
|
This pull request was exported from Phabricator. Differential Revision: D53406924 |
abe44a1 to
2e04cd5
Compare
|
This pull request was exported from Phabricator. Differential Revision: D53406924 |
Summary: This refactors `ReactNativeFeatureFlagsAccessor` in C++ to improve its thread-safety: * It makes all cached feature flags atomic to prevent data corruption when writing them concurrently. * It refactors the list of accessed feature flags to be an array of atomic character pointers instead of a vector. Performance-wise, this is lock-free so it would still be fast enough for our use cases. Semantic-wise, this implementation could lead to feature flags being initialized more than once (if 2 threads happen to access the same feature flag before it has been initialized), but that's ok. The only consequence of this would be accessing the provider twice, but the end state of the accessor is the same (the same value would be cached and the flag would still be marked as accessed). Changelog: [internal] Reviewed By: javache Differential Revision: D53406924
2e04cd5 to
f9eaae4
Compare
|
This pull request was exported from Phabricator. Differential Revision: D53406924 |
|
This pull request has been merged in fe69f71. |
Summary:
This refactors
ReactNativeFeatureFlagsAccessorin C++ to improve its thread-safety:Performance-wise, this is lock-free so it would still be fast enough for our use cases.
Semantic-wise, this implementation could lead to feature flags being initialized more than once (if 2 threads happen to access the same feature flag before it has been initialized), but that's ok. The only consequence of this would be accessing the provider twice, but the end state of the accessor is the same (the same value would be cached and the flag would still be marked as accessed).
Changelog: [internal]
Differential Revision: D53406924