wait with a condition variable instead of a this_thread::sleep_for so that waiting can be cancelled when we stop/shutdown the data thread (see #151)

This commit is contained in:
Benjamin Sergeant
2020-01-28 10:04:32 -08:00
parent 1c7ccbae12
commit 422c7ff855
2 changed files with 8 additions and 2 deletions

View File

@ -22,6 +22,7 @@
#include <mutex>
#include <string>
#include <thread>
#include <condition_variable>
namespace ix
{
@ -140,6 +141,10 @@ namespace ix
static const uint32_t kDefaultMaxWaitBetweenReconnectionRetries;
uint32_t _maxWaitBetweenReconnectionRetries;
// Make the sleeping in the automatic reconnection cancellable
std::mutex _sleepMutex;
std::condition_variable _sleepCondition;
std::atomic<int> _handshakeTimeoutSecs;
static const int kDefaultHandShakeTimeoutSecs;