39template <
typename... Ts>
50 : callbacks(other.copyCallbacks())
58 std::lock_guard<std::mutex> guard(this->mutex);
59 this->callbacks.swap(copy);
71 mutable std::mutex mutex;
75 std::lock_guard<std::mutex> guard(this->mutex);
76 return this->callbacks;
80template <
typename... Ts>
83 std::lock_guard<std::mutex> guard(this->mutex);
84 this->callbacks.push_back(std::move(cb));
85 return --this->callbacks.end();
88template <
typename... Ts>
91 std::lock_guard<std::mutex> guard(this->mutex);
92 if (this->callbacks.size() > 0)
93 this->callbacks.erase(subscription);
96template <
typename... Ts>
99 std::lock_guard<std::mutex> guard(this->mutex);
100 this->callbacks.clear();
103template <
typename... Ts>
109 std::unique_lock<std::mutex> lock(this->mutex);
110 if (this->callbacks.empty())
113 if (this->callbacks.size() == 1)
115 Callback cb = this->callbacks.front();
Event(const Event &other)
Definition event.hpp:49
void unsubscribe(Subscription subscription)
Definition event.hpp:89
std::function< void(Ts...)> Callback
Definition event.hpp:43
CallbacksList::iterator Subscription
Definition event.hpp:45
std::list< Callback > CallbacksList
Definition event.hpp:44
bool fire(Ts... args)
Definition event.hpp:104
Event & operator=(const Event &other)
Definition event.hpp:53
Subscription subscribe(Callback cb)
Definition event.hpp:81
void clear()
Definition event.hpp:97
Definition actions.hpp:25