summaryrefslogtreecommitdiff
path: root/src/event/TimerEvent.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2017-08-29 15:53:57 +0200
committerMax Kellermann <max@musicpd.org>2017-08-29 16:28:27 +0200
commit30a5dd267b6cb9ee21106d5d949de2f04781c6e7 (patch)
tree69403fba4a0f063e25b1e2b10cc71c6a93e48b08 /src/event/TimerEvent.cxx
parent2f0d683378b1520999eb9440318eb6ba33a90992 (diff)
event/TimeoutMonitor: move code to new class TimerEvent
Diffstat (limited to 'src/event/TimerEvent.cxx')
-rw-r--r--src/event/TimerEvent.cxx37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/event/TimerEvent.cxx b/src/event/TimerEvent.cxx
new file mode 100644
index 000000000..0943d8a34
--- /dev/null
+++ b/src/event/TimerEvent.cxx
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2003-2017 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.
+ */
+
+#include "config.h"
+#include "TimerEvent.hxx"
+#include "Loop.hxx"
+
+void
+TimerEvent::Cancel()
+{
+ if (IsActive())
+ loop.CancelTimer(*this);
+}
+
+void
+TimerEvent::Schedule(std::chrono::steady_clock::duration d)
+{
+ Cancel();
+
+ loop.AddTimer(*this, d);
+}