|
|
@ -265,12 +265,13 @@ class AgentImpl { |
|
|
|
const String16& message); |
|
|
|
void SwapBehindLock(MessageQueue* vector1, MessageQueue* vector2); |
|
|
|
void PostIncomingMessage(const String16& message); |
|
|
|
void WaitForFrontendMessage(); |
|
|
|
void NotifyMessageReceived(); |
|
|
|
State ToState(State state); |
|
|
|
|
|
|
|
uv_sem_t start_sem_; |
|
|
|
ConditionVariable pause_cond_; |
|
|
|
Mutex pause_lock_; |
|
|
|
Mutex queue_lock_; |
|
|
|
ConditionVariable incoming_message_cond_; |
|
|
|
Mutex state_lock_; |
|
|
|
uv_thread_t thread_; |
|
|
|
uv_loop_t child_loop_; |
|
|
|
|
|
|
@ -370,15 +371,11 @@ class V8NodeInspector : public v8_inspector::V8InspectorClient { |
|
|
|
return; |
|
|
|
terminated_ = false; |
|
|
|
running_nested_loop_ = true; |
|
|
|
agent_->DispatchMessages(); |
|
|
|
do { |
|
|
|
{ |
|
|
|
Mutex::ScopedLock scoped_lock(agent_->pause_lock_); |
|
|
|
agent_->pause_cond_.Wait(scoped_lock); |
|
|
|
} |
|
|
|
while (!terminated_) { |
|
|
|
agent_->WaitForFrontendMessage(); |
|
|
|
while (v8::platform::PumpMessageLoop(platform_, env_->isolate())) |
|
|
|
{} |
|
|
|
} while (!terminated_); |
|
|
|
} |
|
|
|
terminated_ = false; |
|
|
|
running_nested_loop_ = false; |
|
|
|
} |
|
|
@ -661,7 +658,6 @@ bool AgentImpl::OnInspectorHandshakeIO(InspectorSocket* socket, |
|
|
|
void AgentImpl::OnRemoteDataIO(InspectorSocket* socket, |
|
|
|
ssize_t read, |
|
|
|
const uv_buf_t* buf) { |
|
|
|
Mutex::ScopedLock scoped_lock(pause_lock_); |
|
|
|
if (read > 0) { |
|
|
|
String16 str = String16::fromUTF8(buf->base, read); |
|
|
|
// TODO(pfeldman): Instead of blocking execution while debugger
|
|
|
@ -686,7 +682,6 @@ void AgentImpl::OnRemoteDataIO(InspectorSocket* socket, |
|
|
|
if (buf) { |
|
|
|
delete[] buf->base; |
|
|
|
} |
|
|
|
pause_cond_.Broadcast(scoped_lock); |
|
|
|
} |
|
|
|
|
|
|
|
// static
|
|
|
@ -752,14 +747,14 @@ void AgentImpl::WorkerRunIO() { |
|
|
|
|
|
|
|
bool AgentImpl::AppendMessage(MessageQueue* queue, int session_id, |
|
|
|
const String16& message) { |
|
|
|
Mutex::ScopedLock scoped_lock(queue_lock_); |
|
|
|
Mutex::ScopedLock scoped_lock(state_lock_); |
|
|
|
bool trigger_pumping = queue->empty(); |
|
|
|
queue->push_back(std::make_pair(session_id, message)); |
|
|
|
return trigger_pumping; |
|
|
|
} |
|
|
|
|
|
|
|
void AgentImpl::SwapBehindLock(MessageQueue* vector1, MessageQueue* vector2) { |
|
|
|
Mutex::ScopedLock scoped_lock(queue_lock_); |
|
|
|
Mutex::ScopedLock scoped_lock(state_lock_); |
|
|
|
vector1->swap(*vector2); |
|
|
|
} |
|
|
|
|
|
|
@ -771,6 +766,18 @@ void AgentImpl::PostIncomingMessage(const String16& message) { |
|
|
|
isolate->RequestInterrupt(InterruptCallback, this); |
|
|
|
uv_async_send(data_written_); |
|
|
|
} |
|
|
|
NotifyMessageReceived(); |
|
|
|
} |
|
|
|
|
|
|
|
void AgentImpl::WaitForFrontendMessage() { |
|
|
|
Mutex::ScopedLock scoped_lock(state_lock_); |
|
|
|
if (incoming_message_queue_.empty()) |
|
|
|
incoming_message_cond_.Wait(scoped_lock); |
|
|
|
} |
|
|
|
|
|
|
|
void AgentImpl::NotifyMessageReceived() { |
|
|
|
Mutex::ScopedLock scoped_lock(state_lock_); |
|
|
|
incoming_message_cond_.Broadcast(scoped_lock); |
|
|
|
} |
|
|
|
|
|
|
|
void AgentImpl::OnInspectorConnectionIO(InspectorSocket* socket) { |
|
|
|