mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Improve comment describing inspectorExecutor lifetime (#43856)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/43856 Changelog: [Internal] Reviewed By: motiz88 Differential Revision: D55744630 fbshipit-source-id: 4dc930342948253d4cc3b2d04fc4c474e53fc14d
This commit is contained in:
committed by
Facebook GitHub Bot
parent
71cc8a506b
commit
629159a1e3
@@ -71,9 +71,14 @@ void Instance::initializeBridge(
|
||||
std::condition_variable inspectorInitializedCv;
|
||||
bool inspectorInitialized = false;
|
||||
|
||||
// Schedule work on the inspector thread. inspectorExecutor is guaranteed
|
||||
// to execute this callback, so we can safely run this logic
|
||||
// synchronously and reference parentInspectorTarget_.
|
||||
// Schedule work on the inspector thread. NOTE: We expect this callback
|
||||
// to always execute, given the invariant that `initializeBridge` (this
|
||||
// method) completes before `unregisterFromInspector` is called.
|
||||
// - On iOS, instance creation and invalidation both run on the main
|
||||
// queue (`RCTCxxBridge::start,invalidate` use `RCTAssertMainQueue`).
|
||||
// - On Android, `ReactContext` must be initialized with a constructed
|
||||
// `CatalystInstance` (in which `Instance::initializeBridge` has
|
||||
// completed) before `destroy` can be called.
|
||||
inspectorExecutor([this,
|
||||
&inspectorInitialized,
|
||||
&inspectorInitializedMutex,
|
||||
@@ -81,10 +86,10 @@ void Instance::initializeBridge(
|
||||
jsinspector_modern::HostTarget& hostTarget) {
|
||||
// NOTE: By passing *this, we strongly assume the Instance will still
|
||||
// be alive by the time this executes.
|
||||
// - On iOS, instance creation is done syncrhonously
|
||||
// (RCTCxxBridge#_initializeBridgeLocked).
|
||||
// - On iOS, instance creation is done synchronously
|
||||
// (`RCTCxxBridge::_initializeBridgeLocked`).
|
||||
// - On Android, we explicitly wait for instance creation before
|
||||
// destruction (ReactInstanceManager#mReactContextLock).
|
||||
// destruction (`ReactInstanceManager::mReactContextLock`).
|
||||
inspectorTarget_ = &hostTarget.registerInstance(*this);
|
||||
RuntimeExecutor runtimeExecutorIfJsi = getRuntimeExecutor();
|
||||
runtimeInspectorTarget_ = &inspectorTarget_->registerRuntime(
|
||||
|
||||
@@ -136,7 +136,7 @@ class RN_EXPORT Instance : private jsinspector_modern::InstanceTargetDelegate {
|
||||
|
||||
/**
|
||||
* Unregisters the instance from the inspector. This method must be called
|
||||
* on the main (non-JS) thread.
|
||||
* on the main (non-JS) thread, AFTER \c initializeBridge has completed.
|
||||
*/
|
||||
void unregisterFromInspector();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user