Like most condition variable implementations, std::condition_variable may
wake up spuriously, even though it is not signalled (see
http://en.cppreference.com/w/cpp/thread/condition_variable/wait). Since
the intention of blocking on the std::condition_variable in main is to
wait forever, add a loop to block again after spurious wakeups.
Change-Id: I19b7ee13650b9b80250f935e2099119611fa61b3
Signed-off-by: William Dieter <william.r.dieter@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/355
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Sudarshan Prasad <sudarshan.prasad@intel.com>
std::mutex blocker;
std::condition_variable cv;
std::unique_lock<std::mutex> lock(blocker);
- cv.wait(lock);
+ while(true)
+ {
+ cv.wait(lock);
+ }
}catch(OCException& e)
{