Commit 42ad753e authored by Max Kellermann's avatar Max Kellermann

event/MaskMonitor: migrate from DeferredMonitor to DeferEvent

parent 1ccd2a7b
...@@ -24,11 +24,11 @@ void ...@@ -24,11 +24,11 @@ void
MaskMonitor::OrMask(unsigned new_mask) MaskMonitor::OrMask(unsigned new_mask)
{ {
if (pending_mask.fetch_or(new_mask) == 0) if (pending_mask.fetch_or(new_mask) == 0)
DeferredMonitor::Schedule(); defer.Schedule();
} }
void void
MaskMonitor::RunDeferred() MaskMonitor::RunDeferred() noexcept
{ {
const unsigned mask = pending_mask.exchange(0); const unsigned mask = pending_mask.exchange(0);
if (mask != 0) if (mask != 0)
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#define MPD_EVENT_MASK_MONITOR_HXX #define MPD_EVENT_MASK_MONITOR_HXX
#include "check.h" #include "check.h"
#include "DeferredMonitor.hxx" #include "DeferEvent.hxx"
#include "util/BindMethod.hxx" #include "util/BindMethod.hxx"
#include <atomic> #include <atomic>
...@@ -32,7 +32,9 @@ ...@@ -32,7 +32,9 @@
* *
* This class is thread-safe. * This class is thread-safe.
*/ */
class MaskMonitor final : DeferredMonitor { class MaskMonitor final {
DeferEvent defer;
typedef BoundMethod<void(unsigned)> Callback; typedef BoundMethod<void(unsigned)> Callback;
const Callback callback; const Callback callback;
...@@ -40,16 +42,22 @@ class MaskMonitor final : DeferredMonitor { ...@@ -40,16 +42,22 @@ class MaskMonitor final : DeferredMonitor {
public: public:
MaskMonitor(EventLoop &_loop, Callback _callback) MaskMonitor(EventLoop &_loop, Callback _callback)
:DeferredMonitor(_loop), callback(_callback), pending_mask(0) {} :defer(_loop, BIND_THIS_METHOD(RunDeferred)),
callback(_callback), pending_mask(0) {}
EventLoop &GetEventLoop() {
return defer.GetEventLoop();
}
using DeferredMonitor::GetEventLoop; void Cancel() {
using DeferredMonitor::Cancel; defer.Cancel();
}
void OrMask(unsigned new_mask); void OrMask(unsigned new_mask);
protected: protected:
/* virtual methode from class DeferredMonitor */ /* DeferEvent callback */
void RunDeferred() override; void RunDeferred() noexcept;
}; };
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment