mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-02-10 09:12:46 +08:00
WebWorkers: implement tear down and terminate()
Summary: public Previously we did no cleanup when the executor was torn down and didn't expose a way to tear down the worker from JS. Now we do. Termination happens synchronously and waits the the worker's MessageQueueThread to finish and join. Reviewed By: mhorowitz Differential Revision: D2815240 fb-gh-sync-id: 786beb30d4d64556586b91727f32e379c667a965
This commit is contained in:
committed by
facebook-github-bot-4
parent
b0519c8280
commit
0be36a2c80
@@ -43,4 +43,11 @@ public interface MessageQueueThread {
|
||||
* {@link AssertionError}) if the assertion fails.
|
||||
*/
|
||||
void assertIsOnThread();
|
||||
|
||||
/**
|
||||
* Quits this MessageQueueThread. If called from this MessageQueueThread, this will be the last
|
||||
* thing the thread runs. If called from a separate thread, this will block until the thread can
|
||||
* be quit and joined.
|
||||
*/
|
||||
void quitSynchronous();
|
||||
}
|
||||
|
||||
@@ -101,6 +101,7 @@ public class MessageQueueThreadImpl implements MessageQueueThread {
|
||||
* Quits this queue's Looper. If that Looper was running on a different Thread than the current
|
||||
* Thread, also waits for the last message being processed to finish and the Thread to die.
|
||||
*/
|
||||
@Override
|
||||
public void quitSynchronous() {
|
||||
mIsFinished = true;
|
||||
mLooper.quit();
|
||||
|
||||
Reference in New Issue
Block a user