aboutsummaryrefslogtreecommitdiffstats
path: root/src/event/DeferredMonitor.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/event/DeferredMonitor.cxx')
-rw-r--r--src/event/DeferredMonitor.cxx61
1 files changed, 3 insertions, 58 deletions
diff --git a/src/event/DeferredMonitor.cxx b/src/event/DeferredMonitor.cxx
index 62edb7817..3e824012f 100644
--- a/src/event/DeferredMonitor.cxx
+++ b/src/event/DeferredMonitor.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2013 The Music Player Daemon Project
+ * Copyright (C) 2003-2014 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -24,66 +24,11 @@
void
DeferredMonitor::Cancel()
{
-#ifdef USE_EPOLL
- pending = false;
-#else
- const ScopeLock protect(mutex);
- if (source_id != 0) {
- g_source_remove(source_id);
- source_id = 0;
- }
-#endif
+ loop.RemoveDeferred(*this);
}
void
DeferredMonitor::Schedule()
{
-#ifdef USE_EPOLL
- if (!pending.exchange(true))
- fd.Write();
-#else
- const ScopeLock protect(mutex);
- if (source_id == 0)
- source_id = loop.AddIdle(Callback, this);
-#endif
+ loop.AddDeferred(*this);
}
-
-#ifdef USE_EPOLL
-
-bool
-DeferredMonitor::OnSocketReady(unsigned)
-{
- fd.Read();
-
- if (pending.exchange(false))
- RunDeferred();
-
- return true;
-}
-
-#else
-
-void
-DeferredMonitor::Run()
-{
- {
- const ScopeLock protect(mutex);
- if (source_id == 0)
- /* cancelled */
- return;
-
- source_id = 0;
- }
-
- RunDeferred();
-}
-
-gboolean
-DeferredMonitor::Callback(gpointer data)
-{
- DeferredMonitor &monitor = *(DeferredMonitor *)data;
- monitor.Run();
- return false;
-}
-
-#endif