Support passing native modules to JSContext

Reviewed By: amnn

Differential Revision: D4561036

fbshipit-source-id: b096a222103e895b14cba1ec5b2bb6e72dd72c37
This commit is contained in:
Marc Horowitz
2017-03-14 15:28:49 -07:00
committed by Facebook Github Bot
parent bacee5ad56
commit 7e4b8ff000
3 changed files with 20 additions and 5 deletions

View File

@@ -95,9 +95,13 @@ NativeToJsBridge::NativeToJsBridge(
std::shared_ptr<InstanceCallback> callback)
: m_destroyed(std::make_shared<bool>(false))
, m_mainExecutorToken(callback->createExecutorToken())
, m_delegate(
std::make_shared<JsToNativeBridge>(
this, registry, std::move(nativeQueue), callback)) {
, m_delegate(registry
? std::make_shared<JsToNativeBridge>(
this, registry, std::move(nativeQueue), callback)
: nullptr) {
if (!m_delegate) {
nativeQueue->quitSynchronous();
}
std::unique_ptr<JSExecutor> mainExecutor =
jsExecutorFactory->createJSExecutor(m_delegate, jsQueue);
// cached to avoid locked map lookup in the common case
@@ -314,7 +318,9 @@ ExecutorToken NativeToJsBridge::getTokenForExecutor(JSExecutor& executor) {
}
void NativeToJsBridge::destroy() {
m_delegate->quitQueueSynchronous();
if (m_delegate) {
m_delegate->quitQueueSynchronous();
}
auto* executorMessageQueueThread = getMessageQueueThread(m_mainExecutorToken);
// All calls made through runOnExecutorQueue have an early exit if
// m_destroyed is true. Setting this before the runOnQueueSync will cause