Use libuv to wake up main thread

This commit is contained in:
Cheng Zhao 2015-08-27 13:30:04 +08:00
parent 573c959a75
commit 134ccb550c
2 changed files with 13 additions and 3 deletions

View file

@ -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*>(