From e2bc92d12847e5ee98a23d482731a91d4a180622 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 10 Mar 2016 20:31:08 +0100 Subject: [PATCH] Instance: replace IdleMaskMonitor with CallMaskMonitor --- Makefile.am | 1 - src/IdleMaskMonitor.hxx | 44 ----------------------------------------- src/Instance.hxx | 19 +++++++++++------- 3 files changed, 12 insertions(+), 52 deletions(-) delete mode 100644 src/IdleMaskMonitor.hxx diff --git a/Makefile.am b/Makefile.am index 09b325ca1..7d270a713 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 \ diff --git a/src/IdleMaskMonitor.hxx b/src/IdleMaskMonitor.hxx deleted file mode 100644 index f13f296dd..000000000 --- a/src/IdleMaskMonitor.hxx +++ /dev/null @@ -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 diff --git a/src/Instance.hxx b/src/Instance.hxx index e4a2eed7d..8d5bd975a 100644 --- a/src/Instance.hxx +++ b/src/Instance.hxx @@ -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 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