summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/EventLoop/DummyEventLoop.h')
-rw-r--r--Swiften/EventLoop/DummyEventLoop.h42
1 files changed, 8 insertions, 34 deletions
diff --git a/Swiften/EventLoop/DummyEventLoop.h b/Swiften/EventLoop/DummyEventLoop.h
index 297549e..b41cd09 100644
--- a/Swiften/EventLoop/DummyEventLoop.h
+++ b/Swiften/EventLoop/DummyEventLoop.h
@@ -8,8 +8,8 @@
#include <deque>
-#include <boost/thread/mutex.hpp>
#include <boost/thread/locks.hpp>
+#include <boost/thread/mutex.hpp>
#include <Swiften/Base/API.h>
#include <Swiften/EventLoop/EventLoop.h>
@@ -20,40 +20,14 @@ namespace Swift {
DummyEventLoop();
virtual ~DummyEventLoop();
- void processEvents() {
- while (hasEvents()) {
- /*
- Creating a copy of the to-be-handled Event object because handling
- it can result in a DummyEventLoop::post() call.
- This call would also try to lock the eventsMutex_, resulting in a
- deadlock.
- */
-
- eventsMutex_.lock();
- Event eventCopy = events_[0];
- eventsMutex_.unlock();
-
- handleEvent(eventCopy);
-
- {
- boost::lock_guard<boost::mutex> lock(eventsMutex_);
- events_.pop_front();
- }
- }
- }
-
- bool hasEvents() {
- boost::lock_guard<boost::mutex> lock(eventsMutex_);
- return !events_.empty();
- }
-
- virtual void post(const Event& event) {
- boost::lock_guard<boost::mutex> lock(eventsMutex_);
- events_.push_back(event);
- }
+ void processEvents();
+
+ bool hasEvents();
+
+ virtual void eventPosted();
private:
- boost::mutex eventsMutex_;
- std::deque<Event> events_;
+ bool hasEvents_;
+ boost::mutex hasEventsMutex_;
};
}