diff options
Diffstat (limited to 'Swiften/EventLoop')
| -rw-r--r-- | Swiften/EventLoop/SimpleEventLoop.cpp | 6 | ||||
| -rw-r--r-- | Swiften/EventLoop/SimpleEventLoop.h | 5 |
2 files changed, 8 insertions, 3 deletions
diff --git a/Swiften/EventLoop/SimpleEventLoop.cpp b/Swiften/EventLoop/SimpleEventLoop.cpp index 8191747..7c46ed3 100644 --- a/Swiften/EventLoop/SimpleEventLoop.cpp +++ b/Swiften/EventLoop/SimpleEventLoop.cpp @@ -9,12 +9,18 @@ namespace Swift { void nop() {} SimpleEventLoop::SimpleEventLoop() : isRunning_(true) { } +SimpleEventLoop::~SimpleEventLoop() { + if (!events_.empty()) { + std::cerr << "Warning: Pending events in SimpleEventLoop at destruction time" << std::endl; + } +} + void SimpleEventLoop::run() { while (isRunning_) { std::vector<Event> events; { boost::unique_lock<boost::mutex> lock(eventsMutex_); while (events_.size() == 0) { diff --git a/Swiften/EventLoop/SimpleEventLoop.h b/Swiften/EventLoop/SimpleEventLoop.h index 01afdb2..bd0a07f 100644 --- a/Swiften/EventLoop/SimpleEventLoop.h +++ b/Swiften/EventLoop/SimpleEventLoop.h @@ -1,20 +1,20 @@ -#ifndef SWIFTEN_SimpleEventLoop_H -#define SWIFTEN_SimpleEventLoop_H +#pragma once #include <vector> #include <boost/function.hpp> #include <boost/thread/mutex.hpp> #include <boost/thread/condition_variable.hpp> #include "Swiften/EventLoop/EventLoop.h" namespace Swift { class SimpleEventLoop : public EventLoop { public: SimpleEventLoop(); + ~SimpleEventLoop(); void run(); void stop(); virtual void post(const Event& event); @@ -25,7 +25,6 @@ namespace Swift { bool isRunning_; std::vector<Event> events_; boost::mutex eventsMutex_; boost::condition_variable eventsAvailable_; }; } -#endif |
Swift