From 84efd0425aaf67a8f8d8a40bf030881447d326cc Mon Sep 17 00:00:00 2001 From: Peter Thorson Date: Sun, 20 Oct 2013 14:44:37 -0500 Subject: [PATCH] moves sleep call out of a critical section references #283 --- examples/telemetry_client/telemetry_client.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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++;