diff options
author | Max Kellermann <max@musicpd.org> | 2017-11-12 17:34:06 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2017-11-12 17:34:06 +0100 |
commit | b57e2f55215914b2d1e651635a7f1b0c6d97c91d (patch) | |
tree | 93b107b737659264dd4da297d6f7549c2c46a1fc /src/event/DeferEvent.hxx | |
parent | bf3ced6a341ab8ca11357e94d7da8f7a41069c40 (diff) |
event/DeferredMonitor: eliminate obsolete class
Move its code to DeferEvent instead.
Diffstat (limited to 'src/event/DeferEvent.hxx')
-rw-r--r-- | src/event/DeferEvent.hxx | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/src/event/DeferEvent.hxx b/src/event/DeferEvent.hxx index dbd91090d..9ace5a4ce 100644 --- a/src/event/DeferEvent.hxx +++ b/src/event/DeferEvent.hxx @@ -21,28 +21,49 @@ #define MPD_DEFER_EVENT_HXX #include "check.h" -#include "DeferredMonitor.hxx" #include "util/BindMethod.hxx" +#include <boost/intrusive/list_hook.hpp> + +class EventLoop; + /** * Invoke a method call in the #EventLoop. * * This class is thread-safe. */ -class DeferEvent final : DeferredMonitor { +class DeferEvent final { + friend class EventLoop; + + typedef boost::intrusive::list_member_hook<> ListHook; + ListHook list_hook; + + EventLoop &loop; + typedef BoundMethod<void() noexcept> Callback; const Callback callback; public: - DeferEvent(EventLoop &_loop, Callback _callback) - :DeferredMonitor(_loop), callback(_callback) {} + DeferEvent(EventLoop &_loop, Callback _callback) noexcept + :loop(_loop), callback(_callback) {} - using DeferredMonitor::GetEventLoop; - using DeferredMonitor::Schedule; - using DeferredMonitor::Cancel; + ~DeferEvent() noexcept { + Cancel(); + } + + EventLoop &GetEventLoop() noexcept { + return loop; + } + + void Schedule() noexcept; + void Cancel() noexcept; private: - void RunDeferred() noexcept override { + bool IsPending() const noexcept { + return list_hook.is_linked(); + } + + void RunDeferred() noexcept { callback(); } }; |