db/update/Remove: migrate from DeferredMonitor to DeferEvent
This commit is contained in:
parent
593d82c6a9
commit
13f6b1b344
@ -29,7 +29,7 @@
|
|||||||
* available only there.
|
* available only there.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
UpdateRemoveService::RunDeferred()
|
UpdateRemoveService::RunDeferred() noexcept
|
||||||
{
|
{
|
||||||
/* copy the list and unlock the mutex before invoking
|
/* copy the list and unlock the mutex before invoking
|
||||||
callbacks */
|
callbacks */
|
||||||
@ -65,5 +65,5 @@ UpdateRemoveService::Remove(std::string &&uri)
|
|||||||
was empty; if it was not, then that even was already
|
was empty; if it was not, then that even was already
|
||||||
pending */
|
pending */
|
||||||
if (was_empty)
|
if (was_empty)
|
||||||
DeferredMonitor::Schedule();
|
defer.Schedule();
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#define MPD_UPDATE_REMOVE_HXX
|
#define MPD_UPDATE_REMOVE_HXX
|
||||||
|
|
||||||
#include "check.h"
|
#include "check.h"
|
||||||
#include "event/DeferredMonitor.hxx"
|
#include "event/DeferEvent.hxx"
|
||||||
#include "thread/Mutex.hxx"
|
#include "thread/Mutex.hxx"
|
||||||
#include "Compiler.h"
|
#include "Compiler.h"
|
||||||
|
|
||||||
@ -35,16 +35,19 @@ class DatabaseListener;
|
|||||||
* This class handles #Song removal. It defers the action to the main
|
* This class handles #Song removal. It defers the action to the main
|
||||||
* thread to ensure that all references to the #Song are gone.
|
* thread to ensure that all references to the #Song are gone.
|
||||||
*/
|
*/
|
||||||
class UpdateRemoveService final : DeferredMonitor {
|
class UpdateRemoveService final {
|
||||||
DatabaseListener &listener;
|
DatabaseListener &listener;
|
||||||
|
|
||||||
Mutex mutex;
|
Mutex mutex;
|
||||||
|
|
||||||
std::forward_list<std::string> uris;
|
std::forward_list<std::string> uris;
|
||||||
|
|
||||||
|
DeferEvent defer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UpdateRemoveService(EventLoop &_loop, DatabaseListener &_listener)
|
UpdateRemoveService(EventLoop &_loop, DatabaseListener &_listener)
|
||||||
:DeferredMonitor(_loop), listener(_listener) {}
|
:listener(_listener),
|
||||||
|
defer(_loop, BIND_THIS_METHOD(RunDeferred)) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a signal to the main thread which will in turn remove
|
* Sends a signal to the main thread which will in turn remove
|
||||||
@ -55,8 +58,8 @@ public:
|
|||||||
void Remove(std::string &&uri);
|
void Remove(std::string &&uri);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/* virtual methods from class DeferredMonitor */
|
/* DeferEvent callback */
|
||||||
virtual void RunDeferred() override;
|
void RunDeferred() noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user