diff --git a/examples/telemetry_client/telemetry_client.cpp b/examples/telemetry_client/telemetry_client.cpp index e1bd1df0e5..f3db649aa3 100644 --- a/examples/telemetry_client/telemetry_client.cpp +++ b/examples/telemetry_client/telemetry_client.cpp @@ -97,6 +97,8 @@ public: websocketpp::lib::error_code ec; while(1) { + bool wait = false; + { scoped_lock guard(m_lock); // If the connection has been closed, stop generating telemetry @@ -104,11 +106,15 @@ public: // 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++;