Skip to content

Commit

Permalink
moves sleep call out of a critical section references zaphoyd#283
Browse files Browse the repository at this point in the history
  • Loading branch information
zaphoyd committed Oct 20, 2013
1 parent f4d3640 commit 84efd04
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions examples/telemetry_client/telemetry_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,24 @@ class telemetry_client {
websocketpp::lib::error_code ec;

while(1) {
bool wait = false;

{
scoped_lock guard(m_lock);
// If the connection has been closed, stop generating telemetry
if (m_done) {break;}

// If the connection hasn't been opened yet wait a bit and retry
if (!m_open) {
sleep(1);
continue;
wait = true;
}
}

if (wait) {
sleep(1);
continue;
}

val.str("");
val << "count is " << count++;

Expand Down

0 comments on commit 84efd04

Please sign in to comment.