Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(209)

Unified Diff: runtime/bin/dbg_connection.cc

Issue 10384016: Eliminate busy waiting for debugger connection (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/dbg_connection.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/dbg_connection.cc
===================================================================
--- runtime/bin/dbg_connection.cc (revision 7346)
+++ runtime/bin/dbg_connection.cc (working copy)
@@ -18,6 +18,7 @@
int DebuggerConnectionHandler::listener_fd_ = -1;
int DebuggerConnectionHandler::debugger_fd_ = -1;
+dart::Monitor DebuggerConnectionHandler::is_connected_;
MessageBuffer* DebuggerConnectionHandler::msgbuf_ = NULL;
bool DebuggerConnectionHandler::handler_started_ = false;
@@ -209,7 +210,7 @@
ASSERT(Dart_IsString(script_url));
const char* script_url_chars;
Dart_StringToCString(script_url, &script_url_chars);
- msg.Printf("\"location\": { \"scriptId\": \"%s\", \"lineNumber\": %d }}",
+ msg.Printf("\"location\": { \"url\": \"%s\", \"lineNumber\": %d }}",
script_url_chars, line_number);
}
msg.Printf("]}}");
@@ -220,11 +221,13 @@
void DebuggerConnectionHandler::BreakpointHandler(Dart_Breakpoint bpt,
Dart_StackTrace trace) {
- // TODO(hausner): rather than busy-waiting, block on the pipe to the
- // debugger thread and wait until a debugger connection has been
- // established.
- while (!IsConnected()) {
- // Busy wait.
+ {
+ MonitorLocker ml(&is_connected_);
+ while (!IsConnected()) {
+ printf("Waiting for debugger connection...\n");
+ dart::Monitor::WaitResult res = ml.Wait(dart::Monitor::kNoTimeout);
+ ASSERT(res == dart::Monitor::kNotified);
+ }
}
SendBreakpointEvent(bpt, trace);
HandleMessages();
@@ -238,6 +241,10 @@
debugger_fd_ = debugger_fd;
ASSERT(msgbuf_ == NULL);
msgbuf_ = new MessageBuffer(debugger_fd_);
+ {
+ MonitorLocker ml(&is_connected_);
+ ml.Notify();
+ }
}
void DebuggerConnectionHandler::CloseDbgConnection() {
« no previous file with comments | « runtime/bin/dbg_connection.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698