Fix conditional wait.

Summary: It could happen that the garbage collector waits for the sleep period before exiting thread since notify_one wasn't done after mutex locking.

Reviewers: mislav.bradac

Reviewed By: mislav.bradac

Differential Revision: https://phabricator.memgraph.io/D206
This commit is contained in:
Dominik Gleich 2017-03-30 13:24:54 +02:00
parent 3d2b37ed35
commit cac422f6a8

View File

@ -27,7 +27,10 @@ class GarbageCollector : public Loggable {
~GarbageCollector() {
destruction_.store(true);
condition_variable_.notify_one();
{
std::unique_lock<std::mutex> lk(mutex_);
condition_variable_.notify_one();
}
if (run_thread_.joinable()) run_thread_.join();
}