diff --git a/src/event_loop_dispatcher.hpp b/src/event_loop_dispatcher.hpp index 1d08e036..0e3ff749 100644 --- a/src/event_loop_dispatcher.hpp +++ b/src/event_loop_dispatcher.hpp @@ -45,13 +45,17 @@ template class EventLoopDispatcher { using Tuple = std::tuple::type...>; private: + + struct Callback; + struct State { public: - State(std::function func) : m_func(func) { } + State(std::function func) : m_func(func), m_signal(nullptr) { } const std::function m_func; std::queue m_invocations; std::mutex m_mutex; + std::shared_ptr> m_signal; }; const std::shared_ptr m_state; @@ -67,6 +71,7 @@ private: ::_apply_polyfill::apply(tuple, m_state->m_func); m_state->m_invocations.pop(); } + m_state->m_signal = nullptr; } }; const std::shared_ptr> m_signal; @@ -92,6 +97,7 @@ public: { std::unique_lock lock(m_state->m_mutex); + m_state->m_signal = m_signal; m_state->m_invocations.push(std::make_tuple(args...)); } m_signal->notify();