Instance: replace IdleMaskMonitor with CallMaskMonitor

This commit is contained in:
Max Kellermann 2016-03-10 20:31:08 +01:00
parent 5ffe3773d4
commit e2bc92d128
3 changed files with 12 additions and 52 deletions

View File

@ -95,7 +95,6 @@ libmpd_a_SOURCES = \
src/command/OtherCommands.cxx src/command/OtherCommands.hxx \
src/command/CommandListBuilder.cxx src/command/CommandListBuilder.hxx \
src/Idle.cxx src/Idle.hxx \
src/IdleMaskMonitor.hxx \
src/IdleFlags.cxx src/IdleFlags.hxx \
src/decoder/DecoderError.cxx src/decoder/DecoderError.hxx \
src/decoder/DecoderThread.cxx src/decoder/DecoderThread.hxx \

View File

@ -1,44 +0,0 @@
/*
* Copyright 2003-2016 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_IDLE_MONITOR_HXX
#define MPD_IDLE_MONITOR_HXX
#include "event/MaskMonitor.hxx"
class IdleMaskMonitor : MaskMonitor {
public:
explicit IdleMaskMonitor(EventLoop &_loop)
:MaskMonitor(_loop) {}
void EmitIdle(unsigned mask) {
OrMask(mask);
}
protected:
virtual void OnIdle(unsigned mask) = 0;
private:
/* virtual methods from class MaskMonitor */
void HandleMask(unsigned mask) final {
OnIdle(mask);
}
};
#endif

View File

@ -22,7 +22,7 @@
#include "check.h"
#include "event/Loop.hxx"
#include "IdleMaskMonitor.hxx"
#include "event/MaskMonitor.hxx"
#include "GlobalEvents.hxx"
#include "Compiler.h"
@ -52,8 +52,7 @@ struct EventLoopHolder {
};
struct Instance final
: EventLoopHolder,
IdleMaskMonitor
: EventLoopHolder
#if defined(ENABLE_DATABASE) || defined(ENABLE_NEIGHBOR_PLUGINS)
,
#endif
@ -69,6 +68,8 @@ struct Instance final
{
GlobalEvents::Monitor global_events;
CallbackMaskMonitor<Instance> idle_monitor;
#ifdef ENABLE_NEIGHBOR_PLUGINS
NeighborGlue *neighbors;
#endif
@ -92,8 +93,8 @@ struct Instance final
StateFile *state_file;
Instance()
:IdleMaskMonitor(event_loop),
global_events(event_loop) {}
:global_events(event_loop),
idle_monitor(event_loop, *this, &Instance::OnIdle) {}
/**
* Initiate shutdown. Wrapper for EventLoop::Break().
@ -102,6 +103,10 @@ struct Instance final
event_loop.Break();
}
void EmitIdle(unsigned mask) {
idle_monitor.OrMask(mask);
}
#ifdef ENABLE_DATABASE
/**
* Returns the global #Database instance. May return nullptr
@ -134,8 +139,8 @@ private:
virtual void LostNeighbor(const NeighborInfo &info) override;
#endif
/* virtual methods from class IdleMaskMonitor */
void OnIdle(unsigned mask) override;
/* callback for #idle_monitor */
void OnIdle(unsigned mask);
};
#endif