diff options
Diffstat (limited to 'Swiften/EventLoop/Cocoa')
-rw-r--r-- | Swiften/EventLoop/Cocoa/CocoaEvent.h | 10 | ||||
-rw-r--r-- | Swiften/EventLoop/Cocoa/CocoaEvent.mm | 17 | ||||
-rw-r--r-- | Swiften/EventLoop/Cocoa/CocoaEventLoop.h | 28 | ||||
-rw-r--r-- | Swiften/EventLoop/Cocoa/CocoaEventLoop.mm | 34 |
4 files changed, 47 insertions, 42 deletions
diff --git a/Swiften/EventLoop/Cocoa/CocoaEvent.h b/Swiften/EventLoop/Cocoa/CocoaEvent.h index 4453c74..945056e 100644 --- a/Swiften/EventLoop/Cocoa/CocoaEvent.h +++ b/Swiften/EventLoop/Cocoa/CocoaEvent.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Isode Limited. + * Copyright (c) 2010-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -8,8 +8,12 @@ #include <Foundation/Foundation.h> +// The following line is a workaround for a bug in Boost 1.60 when building as C++11. +// See ticket #11897 and #11863 in Boost's bug tracker. +#undef check + namespace Swift { - class CocoaEventLoop; + class CocoaEventLoop; } // Using deprecated declaration of instance vars in interface, because this @@ -18,7 +22,7 @@ namespace Swift { #pragma clang diagnostic ignored "-Wobjc-interface-ivars" @interface CocoaEvent : NSObject { - Swift::CocoaEventLoop* eventLoop; + Swift::CocoaEventLoop* eventLoop; } #pragma clang diagnostic pop diff --git a/Swiften/EventLoop/Cocoa/CocoaEvent.mm b/Swiften/EventLoop/Cocoa/CocoaEvent.mm index 4f72c29..fc9695b 100644 --- a/Swiften/EventLoop/Cocoa/CocoaEvent.mm +++ b/Swiften/EventLoop/Cocoa/CocoaEvent.mm @@ -1,28 +1,29 @@ /* - * Copyright (c) 2015 Isode Limited. + * Copyright (c) 2015-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/EventLoop/Cocoa/CocoaEvent.h> + #include <Swiften/EventLoop/Cocoa/CocoaEventLoop.h> @implementation CocoaEvent - (id) init:(Swift::CocoaEventLoop*) el { - self = [super init]; - if (self != nil) { - eventLoop = el; - } - return self; + self = [super init]; + if (self != nil) { + eventLoop = el; + } + return self; } - (void) process { - eventLoop->handleNextCocoaEvent(); + eventLoop->handleNextCocoaEvent(); } - (void) dealloc { - [super dealloc]; + [super dealloc]; } @end diff --git a/Swiften/EventLoop/Cocoa/CocoaEventLoop.h b/Swiften/EventLoop/Cocoa/CocoaEventLoop.h index aad6b0a..7f20e6c 100644 --- a/Swiften/EventLoop/Cocoa/CocoaEventLoop.h +++ b/Swiften/EventLoop/Cocoa/CocoaEventLoop.h @@ -1,28 +1,28 @@ /* - * Copyright (c) 2010-2015 Isode Limited. + * Copyright (c) 2010-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once -#include <boost/thread.hpp> +#include <mutex> #include <Swiften/EventLoop/EventLoop.h> namespace Swift { - class CocoaEventLoop : public EventLoop { - public: - CocoaEventLoop(); - virtual ~CocoaEventLoop(); + class CocoaEventLoop : public EventLoop { + public: + CocoaEventLoop(); + virtual ~CocoaEventLoop(); - void handleNextCocoaEvent(); - - protected: - virtual void eventPosted(); + void handleNextCocoaEvent(); - private: - bool isEventInCocoaEventLoop_; - boost::recursive_mutex isEventInCocoaEventLoopMutex_; - }; + protected: + virtual void eventPosted(); + + private: + bool isEventInCocoaEventLoop_; + std::recursive_mutex isEventInCocoaEventLoopMutex_; + }; } diff --git a/Swiften/EventLoop/Cocoa/CocoaEventLoop.mm b/Swiften/EventLoop/Cocoa/CocoaEventLoop.mm index 2d7c613..b8ab621 100644 --- a/Swiften/EventLoop/Cocoa/CocoaEventLoop.mm +++ b/Swiften/EventLoop/Cocoa/CocoaEventLoop.mm @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Isode Limited. + * Copyright (c) 2015-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -19,25 +19,25 @@ CocoaEventLoop::~CocoaEventLoop() { } void CocoaEventLoop::handleNextCocoaEvent() { - { - boost::recursive_mutex::scoped_lock lock(isEventInCocoaEventLoopMutex_); - isEventInCocoaEventLoop_ = false; - } - handleNextEvents(); + { + std::unique_lock<std::recursive_mutex> lock(isEventInCocoaEventLoopMutex_); + isEventInCocoaEventLoop_ = false; + } + handleNextEvents(); } void CocoaEventLoop::eventPosted() { - boost::recursive_mutex::scoped_lock lock(isEventInCocoaEventLoopMutex_); - if (!isEventInCocoaEventLoop_) { - isEventInCocoaEventLoop_ = true; - - CocoaEvent* cocoaEvent = [[CocoaEvent alloc] init: this]; - [cocoaEvent - performSelectorOnMainThread:@selector(process) - withObject: nil - waitUntilDone: NO]; - [cocoaEvent release]; - } + std::unique_lock<std::recursive_mutex> lock(isEventInCocoaEventLoopMutex_); + if (!isEventInCocoaEventLoop_) { + isEventInCocoaEventLoop_ = true; + + CocoaEvent* cocoaEvent = [[CocoaEvent alloc] init: this]; + [cocoaEvent + performSelectorOnMainThread:@selector(process) + withObject: nil + waitUntilDone: NO]; + [cocoaEvent release]; + } } } |