00001
00002
00003
00004
00005
00006
00007 #pragma once
00008
00009 #include <vector>
00010 #include <boost/function.hpp>
00011 #include <boost/thread/mutex.hpp>
00012 #include <boost/thread/condition_variable.hpp>
00013
00014 #include <Swiften/Base/API.h>
00015 #include <Swiften/EventLoop/EventLoop.h>
00016
00017 namespace Swift {
00018 class SWIFTEN_API SimpleEventLoop : public EventLoop {
00019 public:
00020 SimpleEventLoop();
00021 ~SimpleEventLoop();
00022
00023 void run() {
00024 doRun(false);
00025 }
00026
00027 void runUntilEvents() {
00028 doRun(true);
00029 }
00030
00031 void runOnce();
00032
00033 void stop();
00034
00035 virtual void post(const Event& event);
00036
00037 private:
00038 void doRun(bool breakAfterEvents);
00039 void doStop();
00040
00041 private:
00042 bool isRunning_;
00043 std::vector<Event> events_;
00044 boost::mutex eventsMutex_;
00045 boost::condition_variable eventsAvailable_;
00046 };
00047 }