• Main Page
  • Classes
  • Files
  • File List

Swiften/EventLoop/SimpleEventLoop.h

00001 /*
00002  * Copyright (c) 2010 Remko Tronçon
00003  * Licensed under the GNU General Public License v3.
00004  * See Documentation/Licenses/GPLv3.txt for more information.
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 }

Generated on Fri Oct 12 2012 21:00:19 for Swiften by  doxygen 1.7.1