aboutsummaryrefslogtreecommitdiffstats
path: root/src/event/Loop.hxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-01-09 17:50:29 +0100
committerMax Kellermann <max@duempel.org>2014-01-09 17:52:55 +0100
commit61b938d6fad8211d68eb3921e4c68e38b016e7cc (patch)
treee286bd6081c798507e13394e84ecce89729a526f /src/event/Loop.hxx
parent0c34555b02f5d24f8c836534dcc30005a42f2c95 (diff)
downloadmpd-61b938d6fad8211d68eb3921e4c68e38b016e7cc.tar.gz
mpd-61b938d6fad8211d68eb3921e4c68e38b016e7cc.tar.xz
mpd-61b938d6fad8211d68eb3921e4c68e38b016e7cc.zip
event/Loop: allow scheduling events before Run()
Add the debug-only flag "virgin" which gets checked by assert() calls. Fixes assertion failures when using zeroconf/avahi.
Diffstat (limited to '')
-rw-r--r--src/event/Loop.hxx15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/event/Loop.hxx b/src/event/Loop.hxx
index 4bd2a3b2c..d03259fb0 100644
--- a/src/event/Loop.hxx
+++ b/src/event/Loop.hxx
@@ -98,6 +98,14 @@ class EventLoop final : SocketMonitor
*/
bool busy;
+#ifndef NDEBUG
+ /**
+ * True if Run() was never called. This is used for assert()
+ * calls.
+ */
+ bool virgin;
+#endif
+
PollGroup poll_group;
PollResult poll_result;
@@ -200,6 +208,13 @@ public:
#ifndef NDEBUG
gcc_pure
+ bool IsInsideOrVirgin() const {
+ return virgin || IsInside();
+ }
+#endif
+
+#ifndef NDEBUG
+ gcc_pure
bool IsInsideOrNull() const {
return thread.IsNull() || thread.IsInside();
}