diff options
Diffstat (limited to 'Swiften/EventLoop')
-rw-r--r-- | Swiften/EventLoop/Cocoa/CocoaEvent.h | 9 | ||||
-rw-r--r-- | Swiften/EventLoop/Cocoa/CocoaEvent.mm | 0 | ||||
-rw-r--r-- | Swiften/EventLoop/DummyEventLoop.h | 3 | ||||
-rw-r--r-- | Swiften/EventLoop/EventLoop.cpp | 10 | ||||
-rw-r--r-- | Swiften/EventLoop/EventLoop.h | 11 | ||||
-rw-r--r-- | Swiften/EventLoop/EventOwner.h | 4 | ||||
-rw-r--r-- | Swiften/EventLoop/SConscript | 2 | ||||
-rw-r--r-- | Swiften/EventLoop/SimpleEventLoop.cpp | 2 | ||||
-rw-r--r-- | Swiften/EventLoop/SimpleEventLoop.h | 3 | ||||
-rw-r--r-- | Swiften/EventLoop/SingleThreadedEventLoop.cpp | 2 |
10 files changed, 28 insertions, 18 deletions
diff --git a/Swiften/EventLoop/Cocoa/CocoaEvent.h b/Swiften/EventLoop/Cocoa/CocoaEvent.h index bede7ff..89d056f 100644 --- a/Swiften/EventLoop/Cocoa/CocoaEvent.h +++ b/Swiften/EventLoop/Cocoa/CocoaEvent.h @@ -1,4 +1,4 @@ /* - * Copyright (c) 2010 Remko Tronçon + * Copyright (c) 2010-2013 Remko Tronçon * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. @@ -14,4 +14,9 @@ namespace Swift { } +// Using deprecated declaration of instance vars in interface, because this +// is required for older runtimes (e.g. 32-bit Mac OS X) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wobjc-interface-ivars" + @interface CocoaEvent : NSObject { Swift::Event* event; @@ -19,4 +24,6 @@ namespace Swift { } +#pragma clang diagnostic pop + // Takes ownership of event - (id) initWithEvent: (Swift::Event*) e eventLoop: (Swift::CocoaEventLoop*) el; diff --git a/Swiften/EventLoop/Cocoa/CocoaEvent.mm b/Swiften/EventLoop/Cocoa/CocoaEvent.mm index 049e3b6..7b1b4b0 100644 --- a/Swiften/EventLoop/Cocoa/CocoaEvent.mm +++ b/Swiften/EventLoop/Cocoa/CocoaEvent.mm diff --git a/Swiften/EventLoop/DummyEventLoop.h b/Swiften/EventLoop/DummyEventLoop.h index 4c01c16..0e5e06d 100644 --- a/Swiften/EventLoop/DummyEventLoop.h +++ b/Swiften/EventLoop/DummyEventLoop.h @@ -9,8 +9,9 @@ #include <deque> +#include <Swiften/Base/API.h> #include <Swiften/EventLoop/EventLoop.h> namespace Swift { - class DummyEventLoop : public EventLoop { + class SWIFTEN_API DummyEventLoop : public EventLoop { public: DummyEventLoop(); diff --git a/Swiften/EventLoop/EventLoop.cpp b/Swiften/EventLoop/EventLoop.cpp index afb6858..502bc49 100644 --- a/Swiften/EventLoop/EventLoop.cpp +++ b/Swiften/EventLoop/EventLoop.cpp @@ -1,4 +1,4 @@ /* - * Copyright (c) 2010 Remko Tronçon + * Copyright (c) 2010-2013 Remko Tronçon * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. @@ -8,10 +8,14 @@ #include <algorithm> -#include <boost/bind.hpp> #include <iostream> #include <cassert> +#include <boost/bind.hpp> +#include <boost/lambda/lambda.hpp> +#include <boost/lambda/bind.hpp> +#include <boost/thread/locks.hpp> #include <Swiften/Base/Log.h> +namespace lambda = boost::lambda; namespace Swift { @@ -84,5 +88,5 @@ void EventLoop::postEvent(boost::function<void ()> callback, boost::shared_ptr<E void EventLoop::removeEventsFromOwner(boost::shared_ptr<EventOwner> owner) { boost::lock_guard<boost::mutex> lock(eventsMutex_); - events_.remove_if(HasOwner(owner)); + events_.remove_if(lambda::bind(&Event::owner, lambda::_1) == owner); } diff --git a/Swiften/EventLoop/EventLoop.h b/Swiften/EventLoop/EventLoop.h index 9e47112..79ade49 100644 --- a/Swiften/EventLoop/EventLoop.h +++ b/Swiften/EventLoop/EventLoop.h @@ -8,13 +8,15 @@ #include <boost/function.hpp> -#include <boost/thread/mutex.hpp> +#include <boost/thread.hpp> #include <list> #include <deque> +#include <Swiften/Base/API.h> #include <Swiften/EventLoop/Event.h> namespace Swift { class EventOwner; - class EventLoop { + + class SWIFTEN_API EventLoop { public: EventLoop(); @@ -34,9 +36,4 @@ namespace Swift { private: - struct HasOwner { - HasOwner(boost::shared_ptr<EventOwner> owner) : owner(owner) {} - bool operator()(const Event& event) const { return event.owner == owner; } - boost::shared_ptr<EventOwner> owner; - }; boost::mutex eventsMutex_; unsigned int nextEventID_; diff --git a/Swiften/EventLoop/EventOwner.h b/Swiften/EventLoop/EventOwner.h index 4bbd1c4..43a059b 100644 --- a/Swiften/EventLoop/EventOwner.h +++ b/Swiften/EventLoop/EventOwner.h @@ -7,6 +7,8 @@ #pragma once +#include <Swiften/Base/API.h> + namespace Swift { - class EventOwner { + class SWIFTEN_API EventOwner { public: virtual ~EventOwner(); diff --git a/Swiften/EventLoop/SConscript b/Swiften/EventLoop/SConscript index b405f6b..8bef8fb 100644 --- a/Swiften/EventLoop/SConscript +++ b/Swiften/EventLoop/SConscript @@ -13,5 +13,5 @@ objects = swiften_env.SwiftenObject(sources) swiften_env.Append(SWIFTEN_OBJECTS = [objects]) -if swiften_env["PLATFORM"] == "darwin" : +if swiften_env["PLATFORM"] == "darwin" and swiften_env["target"] == "native": myenv = swiften_env.Clone() myenv.Append(CXXFLAGS = myenv["OBJCCFLAGS"]) diff --git a/Swiften/EventLoop/SimpleEventLoop.cpp b/Swiften/EventLoop/SimpleEventLoop.cpp index 63b8ba5..42a5481 100644 --- a/Swiften/EventLoop/SimpleEventLoop.cpp +++ b/Swiften/EventLoop/SimpleEventLoop.cpp @@ -15,6 +15,4 @@ namespace Swift { -void nop() {} - SimpleEventLoop::SimpleEventLoop() : isRunning_(true) { } diff --git a/Swiften/EventLoop/SimpleEventLoop.h b/Swiften/EventLoop/SimpleEventLoop.h index 72bd6a6..da1c039 100644 --- a/Swiften/EventLoop/SimpleEventLoop.h +++ b/Swiften/EventLoop/SimpleEventLoop.h @@ -12,8 +12,9 @@ #include <boost/thread/condition_variable.hpp> +#include <Swiften/Base/API.h> #include <Swiften/EventLoop/EventLoop.h> namespace Swift { - class SimpleEventLoop : public EventLoop { + class SWIFTEN_API SimpleEventLoop : public EventLoop { public: SimpleEventLoop(); diff --git a/Swiften/EventLoop/SingleThreadedEventLoop.cpp b/Swiften/EventLoop/SingleThreadedEventLoop.cpp index 4c5e209..c2235b1 100644 --- a/Swiften/EventLoop/SingleThreadedEventLoop.cpp +++ b/Swiften/EventLoop/SingleThreadedEventLoop.cpp @@ -28,5 +28,5 @@ SingleThreadedEventLoop::~SingleThreadedEventLoop() { void SingleThreadedEventLoop::waitForEvents() { boost::unique_lock<boost::mutex> lock(eventsMutex_); - while (events_.size() == 0 && !shouldShutDown_) { + while (events_.empty() && !shouldShutDown_) { eventsAvailable_.wait(lock); } |