aboutsummaryrefslogtreecommitdiffstats
path: root/src/db/update/Remove.hxx
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/db/update/Remove.hxx (renamed from src/db/update/UpdateRemove.hxx)35
1 files changed, 27 insertions, 8 deletions
diff --git a/src/db/update/UpdateRemove.hxx b/src/db/update/Remove.hxx
index d54e3aa80..1970c0a07 100644
--- a/src/db/update/UpdateRemove.hxx
+++ b/src/db/update/Remove.hxx
@@ -21,18 +21,37 @@
#define MPD_UPDATE_REMOVE_HXX
#include "check.h"
+#include "event/DeferredMonitor.hxx"
+#include "thread/Mutex.hxx"
+#include "thread/Cond.hxx"
struct Song;
-void
-update_remove_global_init(void);
-
/**
- * Sends a signal to the main thread which will in turn remove the
- * song: from the sticker database and from the playlist. This
- * serialized access is implemented to avoid excessive locking.
+ * This class handles #Song removal. It defers the action to the main
+ * thread to ensure that all references to the #Song are gone.
*/
-void
-update_remove_song(const Song *song);
+class UpdateRemoveService final : DeferredMonitor {
+ Mutex remove_mutex;
+ Cond remove_cond;
+
+ const Song *removed_song;
+
+public:
+ UpdateRemoveService(EventLoop &_loop)
+ :DeferredMonitor(_loop) {}
+
+ /**
+ * Sends a signal to the main thread which will in turn remove
+ * the song: from the sticker database and from the playlist.
+ * This serialized access is implemented to avoid excessive
+ * locking.
+ */
+ void Remove(const Song *song);
+
+private:
+ /* virtual methods from class DeferredMonitor */
+ virtual void RunDeferred() override;
+};
#endif