New ConditionVariableNotifier (implementation of NotifierInterface, using an std::condition_variable)
This commit is contained in:
19
src/Helpers/ConditionVariableNotifier.cpp
Normal file
19
src/Helpers/ConditionVariableNotifier.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#include "ConditionVariableNotifier.hpp"
|
||||
|
||||
namespace Bloom
|
||||
{
|
||||
void ConditionVariableNotifier::notify() {
|
||||
auto lock = std::unique_lock(this->mutex);
|
||||
this->notified = true;
|
||||
this->conditionalVariable.notify_all();
|
||||
}
|
||||
|
||||
void ConditionVariableNotifier::waitForNotification() {
|
||||
auto lock = std::unique_lock(this->mutex);
|
||||
this->conditionalVariable.wait(lock, [this] {
|
||||
return this->notified;
|
||||
});
|
||||
|
||||
this->notified = false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user