event/MaskMonitor: migrate from DeferredMonitor to DeferEvent
This commit is contained in:
parent
1ccd2a7b11
commit
42ad753e39
@ -24,11 +24,11 @@ void
|
||||
MaskMonitor::OrMask(unsigned new_mask)
|
||||
{
|
||||
if (pending_mask.fetch_or(new_mask) == 0)
|
||||
DeferredMonitor::Schedule();
|
||||
defer.Schedule();
|
||||
}
|
||||
|
||||
void
|
||||
MaskMonitor::RunDeferred()
|
||||
MaskMonitor::RunDeferred() noexcept
|
||||
{
|
||||
const unsigned mask = pending_mask.exchange(0);
|
||||
if (mask != 0)
|
||||
|
@ -21,7 +21,7 @@
|
||||
#define MPD_EVENT_MASK_MONITOR_HXX
|
||||
|
||||
#include "check.h"
|
||||
#include "DeferredMonitor.hxx"
|
||||
#include "DeferEvent.hxx"
|
||||
#include "util/BindMethod.hxx"
|
||||
|
||||
#include <atomic>
|
||||
@ -32,7 +32,9 @@
|
||||
*
|
||||
* This class is thread-safe.
|
||||
*/
|
||||
class MaskMonitor final : DeferredMonitor {
|
||||
class MaskMonitor final {
|
||||
DeferEvent defer;
|
||||
|
||||
typedef BoundMethod<void(unsigned)> Callback;
|
||||
const Callback callback;
|
||||
|
||||
@ -40,16 +42,22 @@ class MaskMonitor final : DeferredMonitor {
|
||||
|
||||
public:
|
||||
MaskMonitor(EventLoop &_loop, Callback _callback)
|
||||
:DeferredMonitor(_loop), callback(_callback), pending_mask(0) {}
|
||||
:defer(_loop, BIND_THIS_METHOD(RunDeferred)),
|
||||
callback(_callback), pending_mask(0) {}
|
||||
|
||||
using DeferredMonitor::GetEventLoop;
|
||||
using DeferredMonitor::Cancel;
|
||||
EventLoop &GetEventLoop() {
|
||||
return defer.GetEventLoop();
|
||||
}
|
||||
|
||||
void Cancel() {
|
||||
defer.Cancel();
|
||||
}
|
||||
|
||||
void OrMask(unsigned new_mask);
|
||||
|
||||
protected:
|
||||
/* virtual methode from class DeferredMonitor */
|
||||
void RunDeferred() override;
|
||||
/* DeferEvent callback */
|
||||
void RunDeferred() noexcept;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user