diff options
author | Tobias Markmann <tm@ayena.de> | 2016-04-08 08:40:49 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2016-04-12 14:12:45 (GMT) |
commit | b9ad76af13fc1d253845e027f91f22039bf14f9c (patch) | |
tree | c70d592a6bbbaae96e818e1de92e82e53390f393 /Swiften/LinkLocal | |
parent | 4e6713df2d55dc1b2970d9c3b619d2a415e1264f (diff) | |
download | swift-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/LinkLocal')
5 files changed, 17 insertions, 18 deletions
diff --git a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.cpp b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.cpp index e6d8b94..9cfe3cd 100644 --- a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.cpp +++ b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.cpp @@ -51,7 +51,7 @@ std::shared_ptr<DNSSDResolveHostnameQuery> BonjourQuerier::createResolveHostname void BonjourQuerier::addRunningQuery(std::shared_ptr<BonjourQuery> query) { { - boost::lock_guard<boost::mutex> lock(runningQueriesMutex); + std::lock_guard<std::mutex> lock(runningQueriesMutex); runningQueries.push_back(query); } runningQueriesAvailableEvent.notify_one(); @@ -60,7 +60,7 @@ void BonjourQuerier::addRunningQuery(std::shared_ptr<BonjourQuery> query) { void BonjourQuerier::removeRunningQuery(std::shared_ptr<BonjourQuery> query) { { - boost::lock_guard<boost::mutex> lock(runningQueriesMutex); + std::lock_guard<std::mutex> lock(runningQueriesMutex); erase(runningQueries, query); } } @@ -72,7 +72,7 @@ void BonjourQuerier::interruptSelect() { void BonjourQuerier::start() { assert(!thread); - thread = new boost::thread(boost::bind(&BonjourQuerier::run, shared_from_this())); + thread = new std::thread(boost::bind(&BonjourQuerier::run, shared_from_this())); } void BonjourQuerier::stop() { @@ -93,7 +93,7 @@ void BonjourQuerier::run() { fd_set fdSet; int maxSocket; { - boost::unique_lock<boost::mutex> lock(runningQueriesMutex); + std::unique_lock<std::mutex> lock(runningQueriesMutex); if (runningQueries.empty()) { runningQueriesAvailableEvent.wait(lock); if (runningQueries.empty()) { @@ -123,7 +123,7 @@ void BonjourQuerier::run() { } { - boost::lock_guard<boost::mutex> lock(runningQueriesMutex); + std::lock_guard<std::mutex> lock(runningQueriesMutex); foreach(std::shared_ptr<BonjourQuery> query, runningQueries) { if (FD_ISSET(query->getSocketID(), &fdSet)) { query->processResult(); diff --git a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.h b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.h index 199eeb2..77326bc 100644 --- a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.h +++ b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.h @@ -8,9 +8,8 @@ #include <list> #include <memory> - -#include <boost/thread/mutex.hpp> -#include <boost/thread/thread.hpp> +#include <mutex> +#include <thread> #include <Swiften/Base/ByteArray.h> #include <Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuery.h> @@ -46,11 +45,11 @@ namespace Swift { private: EventLoop* eventLoop; bool stopRequested; - boost::thread* thread; - boost::mutex runningQueriesMutex; + std::thread* thread; + std::mutex runningQueriesMutex; std::list< std::shared_ptr<BonjourQuery> > runningQueries; int interruptSelectReadSocket; int interruptSelectWriteSocket; - boost::condition_variable runningQueriesAvailableEvent; + std::condition_variable runningQueriesAvailableEvent; }; } diff --git a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuery.cpp b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuery.cpp index 5f9a98f..b4448c7 100644 --- a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuery.cpp +++ b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuery.cpp @@ -18,12 +18,12 @@ BonjourQuery::~BonjourQuery() { } void BonjourQuery::processResult() { - boost::lock_guard<boost::mutex> lock(sdRefMutex); + std::lock_guard<std::mutex> lock(sdRefMutex); DNSServiceProcessResult(sdRef); } int BonjourQuery::getSocketID() const { - boost::lock_guard<boost::mutex> lock(sdRefMutex); + std::lock_guard<std::mutex> lock(sdRefMutex); return DNSServiceRefSockFD(sdRef); } diff --git a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuery.h b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuery.h index 5520158..d3cebe4 100644 --- a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuery.h +++ b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuery.h @@ -7,8 +7,7 @@ #pragma once #include <memory> - -#include <boost/thread/mutex.hpp> +#include <mutex> #include <dns_sd.h> @@ -35,7 +34,7 @@ namespace Swift { protected: EventLoop* eventLoop; std::shared_ptr<BonjourQuerier> querier; - mutable boost::mutex sdRefMutex; + mutable std::mutex sdRefMutex; DNSServiceRef sdRef; }; } diff --git a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourRegisterQuery.h b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourRegisterQuery.h index 776b434..8b2e955 100644 --- a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourRegisterQuery.h +++ b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourRegisterQuery.h @@ -6,8 +6,9 @@ #pragma once +#include <mutex> + #include <boost/numeric/conversion/cast.hpp> -#include <boost/thread.hpp> #include <Swiften/Base/ByteArray.h> #include <Swiften/EventLoop/EventLoop.h> @@ -43,7 +44,7 @@ namespace Swift { } void updateServiceInfo(const ByteArray& txtRecord) { - boost::lock_guard<boost::mutex> lock(sdRefMutex); + std::lock_guard<std::mutex> lock(sdRefMutex); DNSServiceUpdateRecord(sdRef, nullptr, 0, boost::numeric_cast<unsigned short>(txtRecord.size()), vecptr(txtRecord), 0); } |