diff options
Diffstat (limited to 'Swiften/EventLoop')
| -rw-r--r-- | Swiften/EventLoop/Cocoa/CocoaEvent.mm | 6 | ||||
| -rw-r--r-- | Swiften/EventLoop/Cocoa/CocoaEventLoop.h | 2 | ||||
| -rw-r--r-- | Swiften/EventLoop/Cocoa/CocoaEventLoop.mm | 4 | ||||
| -rw-r--r-- | Swiften/EventLoop/DummyEventLoop.cpp | 24 | ||||
| -rw-r--r-- | Swiften/EventLoop/DummyEventLoop.h | 18 | ||||
| -rw-r--r-- | Swiften/EventLoop/Event.h | 2 | ||||
| -rw-r--r-- | Swiften/EventLoop/EventLoop.cpp | 4 | ||||
| -rw-r--r-- | Swiften/EventLoop/EventLoop.h | 4 | ||||
| -rw-r--r-- | Swiften/EventLoop/EventOwner.cpp | 2 | ||||
| -rw-r--r-- | Swiften/EventLoop/Qt/QtEventLoop.h | 2 | ||||
| -rw-r--r-- | Swiften/EventLoop/SConscript | 1 | ||||
| -rw-r--r-- | Swiften/EventLoop/SimpleEventLoop.cpp | 6 | ||||
| -rw-r--r-- | Swiften/EventLoop/SimpleEventLoop.h | 2 | ||||
| -rw-r--r-- | Swiften/EventLoop/UnitTest/EventLoopTest.cpp | 8 | ||||
| -rw-r--r-- | Swiften/EventLoop/UnitTest/SimpleEventLoopTest.cpp | 4 | 
15 files changed, 53 insertions, 36 deletions
| diff --git a/Swiften/EventLoop/Cocoa/CocoaEvent.mm b/Swiften/EventLoop/Cocoa/CocoaEvent.mm index 8a90983..049e3b6 100644 --- a/Swiften/EventLoop/Cocoa/CocoaEvent.mm +++ b/Swiften/EventLoop/Cocoa/CocoaEvent.mm @@ -1,6 +1,6 @@ -#include "Swiften/EventLoop/Cocoa/CocoaEvent.h" -#include "Swiften/EventLoop/Event.h" -#include "Swiften/EventLoop/Cocoa/CocoaEventLoop.h" +#include <Swiften/EventLoop/Cocoa/CocoaEvent.h> +#include <Swiften/EventLoop/Event.h> +#include <Swiften/EventLoop/Cocoa/CocoaEventLoop.h>  @implementation CocoaEvent  diff --git a/Swiften/EventLoop/Cocoa/CocoaEventLoop.h b/Swiften/EventLoop/Cocoa/CocoaEventLoop.h index 2b60741..60ef32b 100644 --- a/Swiften/EventLoop/Cocoa/CocoaEventLoop.h +++ b/Swiften/EventLoop/Cocoa/CocoaEventLoop.h @@ -6,7 +6,7 @@  #pragma once -#include "Swiften/EventLoop/EventLoop.h" +#include <Swiften/EventLoop/EventLoop.h>  namespace Swift {  	class CocoaEventLoop : public EventLoop { diff --git a/Swiften/EventLoop/Cocoa/CocoaEventLoop.mm b/Swiften/EventLoop/Cocoa/CocoaEventLoop.mm index b90f3c6..ba73884 100644 --- a/Swiften/EventLoop/Cocoa/CocoaEventLoop.mm +++ b/Swiften/EventLoop/Cocoa/CocoaEventLoop.mm @@ -1,5 +1,5 @@ -#include "Swiften/EventLoop/Cocoa/CocoaEventLoop.h" -#include "Swiften/EventLoop/Cocoa/CocoaEvent.h" +#include <Swiften/EventLoop/Cocoa/CocoaEventLoop.h> +#include <Swiften/EventLoop/Cocoa/CocoaEvent.h>  #pragma GCC diagnostic ignored "-Wold-style-cast" diff --git a/Swiften/EventLoop/DummyEventLoop.cpp b/Swiften/EventLoop/DummyEventLoop.cpp new file mode 100644 index 0000000..3741eec --- /dev/null +++ b/Swiften/EventLoop/DummyEventLoop.cpp @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2010 Remko Tronçon + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#include <Swiften/EventLoop/DummyEventLoop.h> + +#include <iostream> + +namespace Swift { + +DummyEventLoop::DummyEventLoop() { +} + +DummyEventLoop::~DummyEventLoop() { +	if (!events_.empty()) { +		std::cerr << "DummyEventLoop: Unhandled events at destruction time" << std::endl; +	} +	events_.clear(); +} + + +} diff --git a/Swiften/EventLoop/DummyEventLoop.h b/Swiften/EventLoop/DummyEventLoop.h index b7ef516..4c01c16 100644 --- a/Swiften/EventLoop/DummyEventLoop.h +++ b/Swiften/EventLoop/DummyEventLoop.h @@ -7,24 +7,14 @@  #pragma once  #include <deque> -#include <iostream> -#include <boost/function.hpp> -#include "Swiften/EventLoop/EventLoop.h" -#include "Swiften/Base/foreach.h" +#include <Swiften/EventLoop/EventLoop.h>  namespace Swift {  	class DummyEventLoop : public EventLoop {  		public: -			DummyEventLoop() { -			} - -			~DummyEventLoop() { -				if (!events_.empty()) { -					std::cerr << "DummyEventLoop: Unhandled events at destruction time" << std::endl; -				} -				events_.clear(); -			} +			DummyEventLoop(); +			~DummyEventLoop();  			void processEvents() {  				while (!events_.empty()) { @@ -34,7 +24,7 @@ namespace Swift {  			}  			bool hasEvents() { -				return events_.size() > 0; +				return !events_.empty();  			}  			virtual void post(const Event& event) { diff --git a/Swiften/EventLoop/Event.h b/Swiften/EventLoop/Event.h index 6f5a9e5..b1d7cac 100644 --- a/Swiften/EventLoop/Event.h +++ b/Swiften/EventLoop/Event.h @@ -9,7 +9,7 @@  #include <boost/shared_ptr.hpp>  #include <boost/function.hpp> -#include "Swiften/EventLoop/EventOwner.h" +#include <Swiften/EventLoop/EventOwner.h>  namespace Swift {  	class Event { diff --git a/Swiften/EventLoop/EventLoop.cpp b/Swiften/EventLoop/EventLoop.cpp index 56bb6ac..2b8f00d 100644 --- a/Swiften/EventLoop/EventLoop.cpp +++ b/Swiften/EventLoop/EventLoop.cpp @@ -4,11 +4,12 @@   * See Documentation/Licenses/GPLv3.txt for more information.   */ -#include "Swiften/EventLoop/EventLoop.h" +#include <Swiften/EventLoop/EventLoop.h>  #include <algorithm>  #include <boost/bind.hpp>  #include <iostream> +#include <cassert>  #include <Swiften/Base/Log.h> @@ -17,6 +18,7 @@ namespace Swift {  inline void invokeCallback(const Event& event) {  	try { +		assert(!event.callback.empty());  		event.callback();  	}  	catch (const std::exception& e) { diff --git a/Swiften/EventLoop/EventLoop.h b/Swiften/EventLoop/EventLoop.h index ab58ffc..9e47112 100644 --- a/Swiften/EventLoop/EventLoop.h +++ b/Swiften/EventLoop/EventLoop.h @@ -11,7 +11,7 @@  #include <list>  #include <deque> -#include "Swiften/EventLoop/Event.h" +#include <Swiften/EventLoop/Event.h>  namespace Swift {  	class EventOwner; @@ -35,7 +35,7 @@ namespace Swift {  		private:  			struct HasOwner {  				HasOwner(boost::shared_ptr<EventOwner> owner) : owner(owner) {} -				bool operator()(const Event& event) { return event.owner == owner; } +				bool operator()(const Event& event) const { return event.owner == owner; }  				boost::shared_ptr<EventOwner> owner;  			};  			boost::mutex eventsMutex_; diff --git a/Swiften/EventLoop/EventOwner.cpp b/Swiften/EventLoop/EventOwner.cpp index 275f1d1..9970499 100644 --- a/Swiften/EventLoop/EventOwner.cpp +++ b/Swiften/EventLoop/EventOwner.cpp @@ -4,7 +4,7 @@   * See Documentation/Licenses/GPLv3.txt for more information.   */ -#include "Swiften/EventLoop/EventOwner.h" +#include <Swiften/EventLoop/EventOwner.h>  namespace Swift { diff --git a/Swiften/EventLoop/Qt/QtEventLoop.h b/Swiften/EventLoop/Qt/QtEventLoop.h index 8f6c709..0097cf9 100644 --- a/Swiften/EventLoop/Qt/QtEventLoop.h +++ b/Swiften/EventLoop/Qt/QtEventLoop.h @@ -10,7 +10,7 @@  #include <QEvent>  #include <QCoreApplication> -#include "Swiften/EventLoop/EventLoop.h" +#include <Swiften/EventLoop/EventLoop.h>  namespace Swift {  	class QtEventLoop : public QObject, public EventLoop { diff --git a/Swiften/EventLoop/SConscript b/Swiften/EventLoop/SConscript index 21ae8b9..e448f43 100644 --- a/Swiften/EventLoop/SConscript +++ b/Swiften/EventLoop/SConscript @@ -5,6 +5,7 @@ sources = [  		"EventOwner.cpp",  		"Event.cpp",  		"SimpleEventLoop.cpp", +		"DummyEventLoop.cpp",  	]  objects = swiften_env.SwiftenObject(sources) diff --git a/Swiften/EventLoop/SimpleEventLoop.cpp b/Swiften/EventLoop/SimpleEventLoop.cpp index b77639c..63b8ba5 100644 --- a/Swiften/EventLoop/SimpleEventLoop.cpp +++ b/Swiften/EventLoop/SimpleEventLoop.cpp @@ -4,12 +4,12 @@   * See Documentation/Licenses/GPLv3.txt for more information.   */ -#include "Swiften/EventLoop/SimpleEventLoop.h" +#include <Swiften/EventLoop/SimpleEventLoop.h>  #include <boost/bind.hpp>  #include <iostream> -#include "Swiften/Base/foreach.h" +#include <Swiften/Base/foreach.h>  namespace Swift { @@ -30,7 +30,7 @@ void SimpleEventLoop::doRun(bool breakAfterEvents) {  		std::vector<Event> events;  		{  			boost::unique_lock<boost::mutex> lock(eventsMutex_); -			while (events_.size() == 0) { +			while (events_.empty()) {  				eventsAvailable_.wait(lock);  			}  			events.swap(events_); diff --git a/Swiften/EventLoop/SimpleEventLoop.h b/Swiften/EventLoop/SimpleEventLoop.h index 6fb3f53..72bd6a6 100644 --- a/Swiften/EventLoop/SimpleEventLoop.h +++ b/Swiften/EventLoop/SimpleEventLoop.h @@ -11,7 +11,7 @@  #include <boost/thread/mutex.hpp>  #include <boost/thread/condition_variable.hpp> -#include "Swiften/EventLoop/EventLoop.h" +#include <Swiften/EventLoop/EventLoop.h>  namespace Swift {  	class SimpleEventLoop : public EventLoop { diff --git a/Swiften/EventLoop/UnitTest/EventLoopTest.cpp b/Swiften/EventLoop/UnitTest/EventLoopTest.cpp index b777c1b..58396e6 100644 --- a/Swiften/EventLoop/UnitTest/EventLoopTest.cpp +++ b/Swiften/EventLoop/UnitTest/EventLoopTest.cpp @@ -9,10 +9,10 @@  #include <boost/thread.hpp>  #include <boost/bind.hpp> -#include "Swiften/EventLoop/EventOwner.h" -#include "Swiften/EventLoop/SimpleEventLoop.h" -#include "Swiften/EventLoop/DummyEventLoop.h" -#include "Swiften/Base/sleep.h" +#include <Swiften/EventLoop/EventOwner.h> +#include <Swiften/EventLoop/SimpleEventLoop.h> +#include <Swiften/EventLoop/DummyEventLoop.h> +#include <Swiften/Base/sleep.h>  using namespace Swift; diff --git a/Swiften/EventLoop/UnitTest/SimpleEventLoopTest.cpp b/Swiften/EventLoop/UnitTest/SimpleEventLoopTest.cpp index b779bed..475b6b5 100644 --- a/Swiften/EventLoop/UnitTest/SimpleEventLoopTest.cpp +++ b/Swiften/EventLoop/UnitTest/SimpleEventLoopTest.cpp @@ -9,8 +9,8 @@  #include <boost/thread.hpp>  #include <boost/bind.hpp> -#include "Swiften/EventLoop/SimpleEventLoop.h" -#include "Swiften/Base/sleep.h" +#include <Swiften/EventLoop/SimpleEventLoop.h> +#include <Swiften/Base/sleep.h>  using namespace Swift; | 
 Swift
 Swift