summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-04-08 08:40:49 (GMT)
committerTobias Markmann <tm@ayena.de>2016-04-12 14:12:45 (GMT)
commitb9ad76af13fc1d253845e027f91f22039bf14f9c (patch)
treec70d592a6bbbaae96e818e1de92e82e53390f393 /Swiften/Base
parent4e6713df2d55dc1b2970d9c3b619d2a415e1264f (diff)
downloadswift-b9ad76af13fc1d253845e027f91f22039bf14f9c.zip
swift-b9ad76af13fc1d253845e027f91f22039bf14f9c.tar.bz2
Use C++11 threading library instead of Boost.Thread
This cuts down our dependency on Boost further. Another benefit is that mutex classes of C++11 standard library are recognized by TSAN. Test-Information: Unit and integration tests pass on OS X 10.11.4. Change-Id: Id4dcdb42e3d5155e107ce1d7618acbf26f913b6f
Diffstat (limited to 'Swiften/Base')
-rw-r--r--Swiften/Base/Atomic.h11
-rw-r--r--Swiften/Base/sleep.cpp15
2 files changed, 9 insertions, 17 deletions
diff --git a/Swiften/Base/Atomic.h b/Swiften/Base/Atomic.h
index 9640500..ae065d4 100644
--- a/Swiften/Base/Atomic.h
+++ b/Swiften/Base/Atomic.h
@@ -1,13 +1,12 @@
/*
- * Copyright (c) 2015 Isode Limited.
+ * Copyright (c) 2015-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#pragma once
-#include <boost/thread.hpp>
-#include <boost/thread/locks.hpp>
+#include <mutex>
namespace Swift {
@@ -24,7 +23,7 @@ class Atomic {
* Synchronized write access.
*/
Atomic<ValueType>& operator=(const ValueType& newValue) {
- boost::lock_guard<boost::mutex> lock(valueMutex_);
+ std::lock_guard<std::mutex> lock(valueMutex_);
value_ = newValue;
return *this;
}
@@ -33,12 +32,12 @@ class Atomic {
* Synchronized read access.
*/
operator ValueType() {
- boost::lock_guard<boost::mutex> lock(valueMutex_);
+ std::lock_guard<std::mutex> lock(valueMutex_);
return value_;
}
private:
- boost::mutex valueMutex_;
+ std::mutex valueMutex_;
ValueType value_;
};
diff --git a/Swiften/Base/sleep.cpp b/Swiften/Base/sleep.cpp
index 5a0d729..48eae51 100644
--- a/Swiften/Base/sleep.cpp
+++ b/Swiften/Base/sleep.cpp
@@ -1,25 +1,18 @@
/*
- * Copyright (c) 2010 Isode Limited.
+ * Copyright (c) 2010-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Swiften/Base/sleep.h>
-#include <boost/thread.hpp>
-#include <boost/version.hpp>
+#include <chrono>
+#include <thread>
namespace Swift {
void sleep(unsigned int msecs) {
- boost::xtime xt;
-#if BOOST_VERSION >= 105000
- boost::xtime_get(&xt, boost::TIME_UTC_);
-#else
- boost::xtime_get(&xt, boost::TIME_UTC);
-#endif
- xt.nsec += msecs*1000000;
- boost::thread::sleep(xt);
+ std::this_thread::sleep_for(std::chrono::milliseconds(msecs));
}
}