зеркало из https://github.com/electron/electron.git
Use libuv to wake up main thread
This commit is contained in:
Родитель
573c959a75
Коммит
134ccb550c
|
@ -59,6 +59,8 @@ NodeDebugger::NodeDebugger(v8::Isolate* isolate)
|
|||
if (wait_for_connection)
|
||||
v8::Debug::DebugBreak(isolate_);
|
||||
|
||||
uv_async_init(uv_default_loop(), &weak_up_ui_handle_, ProcessMessageInUI);
|
||||
|
||||
// Start a new IO thread.
|
||||
base::Thread::Options options;
|
||||
options.message_loop_type = base::MessageLoop::TYPE_IO;
|
||||
|
@ -106,9 +108,7 @@ void NodeDebugger::OnMessage(const std::string& message) {
|
|||
isolate_,
|
||||
reinterpret_cast<const uint16_t*>(message16.data()), message16.size());
|
||||
|
||||
content::BrowserThread::PostTask(
|
||||
content::BrowserThread::UI, FROM_HERE,
|
||||
base::Bind(&v8::Debug::ProcessDebugMessages));
|
||||
uv_async_send(&weak_up_ui_handle_);
|
||||
}
|
||||
|
||||
void NodeDebugger::SendMessage(const std::string& message) {
|
||||
|
@ -130,6 +130,11 @@ void NodeDebugger::SendConnectMessage() {
|
|||
v8::V8::GetVersion(), ATOM_PRODUCT_NAME, kContentLength), true);
|
||||
}
|
||||
|
||||
// static
|
||||
void NodeDebugger::ProcessMessageInUI(uv_async_t* handle) {
|
||||
v8::Debug::ProcessDebugMessages();
|
||||
}
|
||||
|
||||
// static
|
||||
void NodeDebugger::DebugMessageHandler(const v8::Debug::Message& message) {
|
||||
NodeDebugger* self = static_cast<NodeDebugger*>(
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "base/threading/thread.h"
|
||||
#include "net/test/embedded_test_server/stream_listen_socket.h"
|
||||
#include "v8/include/v8-debug.h"
|
||||
#include "vendor/node/deps/uv/include/uv.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
|
@ -30,6 +31,8 @@ class NodeDebugger : public net::test_server::StreamListenSocket::Delegate {
|
|||
void SendMessage(const std::string& message);
|
||||
void SendConnectMessage();
|
||||
|
||||
static void ProcessMessageInUI(uv_async_t* handle);
|
||||
|
||||
static void DebugMessageHandler(const v8::Debug::Message& message);
|
||||
|
||||
// net::test_server::StreamListenSocket::Delegate:
|
||||
|
@ -43,6 +46,8 @@ class NodeDebugger : public net::test_server::StreamListenSocket::Delegate {
|
|||
|
||||
v8::Isolate* isolate_;
|
||||
|
||||
uv_async_t weak_up_ui_handle_;
|
||||
|
||||
base::Thread thread_;
|
||||
scoped_ptr<net::test_server::StreamListenSocket> server_;
|
||||
scoped_ptr<net::test_server::StreamListenSocket> accepted_socket_;
|
||||
|
|
Загрузка…
Ссылка в новой задаче