summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/EventLoop/SingleThreadedEventLoop.cpp')
-rw-r--r--Swiften/EventLoop/SingleThreadedEventLoop.cpp51
1 files changed, 28 insertions, 23 deletions
diff --git a/Swiften/EventLoop/SingleThreadedEventLoop.cpp b/Swiften/EventLoop/SingleThreadedEventLoop.cpp
index d617534..0542f37 100644
--- a/Swiften/EventLoop/SingleThreadedEventLoop.cpp
+++ b/Swiften/EventLoop/SingleThreadedEventLoop.cpp
@@ -4,17 +4,21 @@
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
-#include "Swiften/EventLoop/SingleThreadedEventLoop.h"
+/*
+ * Copyright (c) 2016 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
-#include <boost/bind.hpp>
-#include <iostream>
+#include <Swiften/EventLoop/SingleThreadedEventLoop.h>
-#include "Swiften/Base/foreach.h"
+#include <iostream>
+#include <boost/bind.hpp>
namespace Swift {
-SingleThreadedEventLoop::SingleThreadedEventLoop()
+SingleThreadedEventLoop::SingleThreadedEventLoop()
: shouldShutDown_(false), eventAvailable_(false)
{
}
@@ -24,33 +28,34 @@ SingleThreadedEventLoop::~SingleThreadedEventLoop() {
}
void SingleThreadedEventLoop::waitForEvents() {
- boost::unique_lock<boost::mutex> lock(eventAvailableMutex_);
- while (!eventAvailable_ && !shouldShutDown_) {
- eventAvailableCondition_.wait(lock);
- }
-
- if (shouldShutDown_)
- throw EventLoopCanceledException();
+ std::unique_lock<std::mutex> lock(eventAvailableMutex_);
+ while (!eventAvailable_ && !shouldShutDown_) {
+ eventAvailableCondition_.wait(lock);
+ }
+
+ if (shouldShutDown_) {
+ throw EventLoopCanceledException();
+ }
}
void SingleThreadedEventLoop::handleEvents() {
- {
- boost::lock_guard<boost::mutex> lock(eventAvailableMutex_);
- eventAvailable_ = false;
- }
- handleNextEvents();
+ {
+ std::lock_guard<std::mutex> lock(eventAvailableMutex_);
+ eventAvailable_ = false;
+ }
+ handleNextEvents();
}
void SingleThreadedEventLoop::stop() {
- boost::unique_lock<boost::mutex> lock(eventAvailableMutex_);
- shouldShutDown_ = true;
- eventAvailableCondition_.notify_one();
+ std::unique_lock<std::mutex> lock(eventAvailableMutex_);
+ shouldShutDown_ = true;
+ eventAvailableCondition_.notify_one();
}
void SingleThreadedEventLoop::eventPosted() {
- boost::lock_guard<boost::mutex> lock(eventAvailableMutex_);
- eventAvailable_ = true;
- eventAvailableCondition_.notify_one();
+ std::lock_guard<std::mutex> lock(eventAvailableMutex_);
+ eventAvailable_ = true;
+ eventAvailableCondition_.notify_one();
}
} // namespace Swift