Make isInspectable safe to call from any thread

Summary: The bridge was not properly isolating isInspectable onto the JS thread.

Reviewed By: fkgozali

Differential Revision: D14991970

fbshipit-source-id: 92a06c90bade8f92bfa81fa3b7dfb23b17db6117
This commit is contained in:
Marc Horowitz
2019-04-17 21:17:51 -07:00
committed by Facebook Github Bot
parent 1149d85b9f
commit 0735873fbc
2 changed files with 12 additions and 6 deletions

View File

@@ -84,14 +84,15 @@ private:
};
NativeToJsBridge::NativeToJsBridge(
JSExecutorFactory* jsExecutorFactory,
JSExecutorFactory *jsExecutorFactory,
std::shared_ptr<ModuleRegistry> registry,
std::shared_ptr<MessageQueueThread> jsQueue,
std::shared_ptr<InstanceCallback> callback)
: m_destroyed(std::make_shared<bool>(false))
, m_delegate(std::make_shared<JsToNativeBridge>(registry, callback))
, m_executor(jsExecutorFactory->createJSExecutor(m_delegate, jsQueue))
, m_executorMessageQueueThread(std::move(jsQueue)) {}
: m_destroyed(std::make_shared<bool>(false)),
m_delegate(std::make_shared<JsToNativeBridge>(registry, callback)),
m_executor(jsExecutorFactory->createJSExecutor(m_delegate, jsQueue)),
m_executorMessageQueueThread(std::move(jsQueue)),
m_inspectable(m_executor->isInspectable()) {}
// This must be called on the same thread on which the constructor was called.
NativeToJsBridge::~NativeToJsBridge() {
@@ -225,7 +226,7 @@ void* NativeToJsBridge::getJavaScriptContext() {
}
bool NativeToJsBridge::isInspectable() {
return m_executor->isInspectable();
return m_inspectable;
}
bool NativeToJsBridge::isBatchActive() {