Cancel pending bridge work during shutdown
Reviewed By: mhorowitz Differential Revision: D3381541 fbshipit-source-id: 51a3f766509ec78262792817dee3d5e6969ff05f
This commit is contained in:
parent
68c11e55ee
commit
db3adb4445
|
@ -312,12 +312,15 @@ ExecutorToken NativeToJsBridge::getTokenForExecutor(JSExecutor& executor) {
|
|||
void NativeToJsBridge::destroy() {
|
||||
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
|
||||
// pending work to be cancelled and we won't have to wait for it.
|
||||
*m_destroyed = true;
|
||||
executorMessageQueueThread->runOnQueueSync([this, executorMessageQueueThread] {
|
||||
m_mainExecutor->destroy();
|
||||
executorMessageQueueThread->quitSynchronous();
|
||||
unregisterExecutor(*m_mainExecutor);
|
||||
m_mainExecutor = nullptr;
|
||||
*m_destroyed = true;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue