Permalink
Browse files

Debugger: Poll frequently after stepping.

This will make us listen for events slightly less often, so we don't want
to sustain it.
  • Loading branch information...
unknownbrackets committed May 1, 2018
1 parent fc8ad3b commit 2f3b6c19d006f4d2f58c456466f07c88dc56de42
@@ -129,6 +129,8 @@ void HandleDebuggerRequest(const http::Request &request) {
subscriberData.push_back(info.init(eventHandlers));
}
// There's a tradeoff between responsiveness to incoming events, and polling for changes.
int highActivity = 0;
ws->SetTextHandler([&](const std::string &t) {
JsonReader reader(t.c_str(), t.size());
if (!reader.ok()) {
@@ -148,7 +150,10 @@ void HandleDebuggerRequest(const http::Request &request) {
if (eventFunc != eventHandlers.end()) {
std::lock_guard<std::mutex> guard(lifecycleLock);
eventFunc->second(req);
req.Finish();
if (!req.Finish()) {
// Poll more frequently for a second in case this triggers something.
highActivity = 1000;
}
} else {
req.Fail("Bad message: unknown event");
}
@@ -157,7 +162,7 @@ void HandleDebuggerRequest(const http::Request &request) {
ws->Send(DebuggerErrorEvent("Bad message", LogTypes::LERROR));
});
while (ws->Process(1.0f / 60.0f)) {
while (ws->Process(highActivity ? 1.0f / 1000.0f : 1.0f / 60.0f)) {
std::lock_guard<std::mutex> guard(lifecycleLock);
// These send events that aren't just responses to requests.
logger.Broadcast(ws);
@@ -167,6 +172,9 @@ void HandleDebuggerRequest(const http::Request &request) {
if (stopRequested) {
ws->Close(net::WebSocketClose::GOING_AWAY);
}
if (highActivity > 0) {
highActivity--;
}
}
std::lock_guard<std::mutex> guard(lifecycleLock);
@@ -29,7 +29,7 @@ JsonWriter &DebuggerRequest::Respond() {
return writer_;
}
void DebuggerRequest::Finish() {
bool DebuggerRequest::Finish() {
if (responseBegun_ && !responseSent_) {
writer_.end();
if (responsePartial_)
@@ -40,6 +40,8 @@ void DebuggerRequest::Finish() {
responseSent_ = true;
responsePartial_ = false;
}
return responseSent_;
}
void DebuggerRequest::Flush() {
@@ -86,7 +86,7 @@ struct DebuggerRequest {
JsonWriter &Respond();
void Flush();
void Finish();
bool Finish();
private:
JsonWriter writer_;

0 comments on commit 2f3b6c1

Please sign in to comment.