New ConditionVariableNotifier (implementation of NotifierInterface, using an std::condition_variable)

This commit is contained in:
Nav
2022-04-15 22:13:50 +01:00
parent 3b0b39fe83
commit bd6a5d5051
3 changed files with 64 additions and 0 deletions

View 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;
}
}