6#include "TTauri/Foundation/required.hpp"
20template<
typename... Args>
27 mutable bool executing_callbacks =
false;
37 auto lock = std::scoped_lock(mutex);
38 tt_assert(!executing_callbacks);
51 auto lock = std::scoped_lock(mutex);
53 ttlet
id =
add(callback);
55 executing_callbacks =
true;
57 executing_callbacks =
false;
66 auto lock = std::scoped_lock(mutex);
67 tt_assert(!executing_callbacks);
70 return item.first == id;
72 callbacks.
erase(new_end, callbacks.
cend());
79 auto lock = std::scoped_lock(mutex);
80 tt_assert(!executing_callbacks);
82 executing_callbacks =
true;
83 for (ttlet &[
id, callback] : callbacks) {
86 executing_callbacks =
false;
A notifier which can be used to call a set of registred callbacks.
Definition notifier.hpp:21
void remove(size_t id) noexcept
Remove a callback from the notifier.
Definition notifier.hpp:65
size_t add(callback_type callback) noexcept
Add a callback to the notifier.
Definition notifier.hpp:36
size_t add_and_call(callback_type callback, Args const &... args) noexcept
Add a callback to the notifier and invoke it.
Definition notifier.hpp:50
void operator()(Args const &... args) const noexcept
Call the registerd callbacks with the given arguments.
Definition notifier.hpp:78
Definition range_map.hpp:119
T emplace_back(T... args)