aboutsummaryrefslogtreecommitdiff
path: root/src/notify.hxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-01-10 10:44:04 +0100
committerMax Kellermann <max@duempel.org>2013-01-10 10:44:04 +0100
commitb8cda53bd36809b6f61c2e42a673dfdcd43f0c1d (patch)
tree297e3f5d87d2304a7311549399d1896d377d0099 /src/notify.hxx
parente0a97a030fc4c6f978b2855c32f5da98b3e7fb78 (diff)
notify: convert to C++
Diffstat (limited to 'src/notify.hxx')
-rw-r--r--src/notify.hxx53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/notify.hxx b/src/notify.hxx
new file mode 100644
index 00000000..6b9e9536
--- /dev/null
+++ b/src/notify.hxx
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2003-2013 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_NOTIFY_HXX
+#define MPD_NOTIFY_HXX
+
+#include "thread/Mutex.hxx"
+#include "thread/Cond.hxx"
+
+struct notify {
+ Mutex mutex;
+ Cond cond;
+ bool pending;
+
+#ifndef WIN32
+ constexpr
+#endif
+ notify():pending(false) {}
+
+ /**
+ * Wait for a notification. Return immediately if we have already
+ * been notified since we last returned from notify_wait().
+ */
+ void Wait();
+
+ /**
+ * Notify the thread. This function never blocks.
+ */
+ void Signal();
+
+ /**
+ * Clears a pending notification.
+ */
+ void Clear();
+};
+
+#endif