summaryrefslogtreecommitdiff
path: root/src/event/Loop.hxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-01-05 01:40:50 +0100
committerMax Kellermann <max@duempel.org>2014-01-05 02:14:31 +0100
commit626895577840f25c1b0b1f3208310a82c4202d58 (patch)
tree71329824b174eb19564604c8c9e5bc899b937425 /src/event/Loop.hxx
parent4ddfc6e9a2930ede249556548bae370b68af0fbc (diff)
event/Loop: add thread-safety assertions
Diffstat (limited to 'src/event/Loop.hxx')
-rw-r--r--src/event/Loop.hxx13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/event/Loop.hxx b/src/event/Loop.hxx
index b8d090eb5..e8c737e1e 100644
--- a/src/event/Loop.hxx
+++ b/src/event/Loop.hxx
@@ -102,6 +102,8 @@ public:
* A caching wrapper for MonotonicClockMS().
*/
unsigned GetTimeMS() const {
+ assert(IsInside());
+
return now_ms;
}
@@ -113,10 +115,14 @@ public:
void Break();
bool AddFD(int _fd, unsigned flags, SocketMonitor &m) {
+ assert(thread.IsNull() || thread.IsInside());
+
return poll_group.Add(_fd, flags, &m);
}
bool ModifyFD(int _fd, unsigned flags, SocketMonitor &m) {
+ assert(IsInside());
+
return poll_group.Modify(_fd, flags, &m);
}
@@ -177,6 +183,13 @@ public:
return thread.IsInside();
}
+
+#ifndef NDEBUG
+ gcc_pure
+ bool IsInsideOrNull() const {
+ return thread.IsNull() || thread.IsInside();
+ }
+#endif
};
#endif /* MAIN_NOTIFY_H */