From 626895577840f25c1b0b1f3208310a82c4202d58 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 5 Jan 2014 01:40:50 +0100 Subject: event/Loop: add thread-safety assertions --- src/event/Loop.hxx | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/event/Loop.hxx') 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 */ -- cgit v1.2.3