mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Revert D2926896 WebWorkers: Move web worker impl to JSCExecutor
Reviewed By: lexs Differential Revision: D2982150 fb-gh-sync-id: c75d05988df50b9788608e7c1bf00c4952ccfce1 shipit-source-id: c75d05988df50b9788608e7c1bf00c4952ccfce1
This commit is contained in:
committed by
Facebook Github Bot 0
parent
50141f9d3f
commit
c32e5fd84f
@@ -2,9 +2,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <condition_variable>
|
||||
#include <functional>
|
||||
#include <mutex>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
@@ -16,24 +14,6 @@ class MessageQueueThread {
|
||||
virtual bool isOnThread() = 0;
|
||||
// quitSynchronous() should synchronously ensure that no further tasks will run on the queue.
|
||||
virtual void quitSynchronous() = 0;
|
||||
|
||||
void runOnQueueSync(std::function<void()>&& runnable) {
|
||||
std::mutex signalMutex;
|
||||
std::condition_variable signalCv;
|
||||
bool runnableComplete = false;
|
||||
|
||||
runOnQueue([&] () mutable {
|
||||
std::lock_guard<std::mutex> lock(signalMutex);
|
||||
|
||||
runnable();
|
||||
runnableComplete = true;
|
||||
|
||||
signalCv.notify_one();
|
||||
});
|
||||
|
||||
std::unique_lock<std::mutex> lock(signalMutex);
|
||||
signalCv.wait(lock, [&runnableComplete] { return runnableComplete; });
|
||||
}
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user