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/Network/BoostConnection.cpp | |
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/Network/BoostConnection.cpp')
-rw-r--r-- | Swiften/Network/BoostConnection.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Swiften/Network/BoostConnection.cpp b/Swiften/Network/BoostConnection.cpp index a987790..0de7b25 100644 --- a/Swiften/Network/BoostConnection.cpp +++ b/Swiften/Network/BoostConnection.cpp @@ -8,13 +8,13 @@ #include <algorithm> #include <memory> +#include <mutex> #include <string> #include <boost/asio/placeholders.hpp> #include <boost/asio/write.hpp> #include <boost/bind.hpp> #include <boost/numeric/conversion/cast.hpp> -#include <boost/thread.hpp> #include <Swiften/Base/Algorithm.h> #include <Swiften/Base/ByteArray.h> @@ -76,7 +76,7 @@ void BoostConnection::disconnect() { // Mac OS X apparently exhibits a problem where closing a socket during a write could potentially go into uninterruptable sleep. // See e.g. http://bugs.python.org/issue7401 // We therefore wait until any pending write finishes, which hopefully should fix our hang on exit during close(). - boost::lock_guard<boost::mutex> lock(writeMutex_); + std::lock_guard<std::mutex> lock(writeMutex_); if (writing_) { closeSocketAfterNextWrite_ = true; } else { @@ -85,14 +85,14 @@ void BoostConnection::disconnect() { } void BoostConnection::closeSocket() { - boost::lock_guard<boost::mutex> lock(readCloseMutex_); + std::lock_guard<std::mutex> lock(readCloseMutex_); boost::system::error_code errorCode; socket_.shutdown(boost::asio::ip::tcp::socket::shutdown_both, errorCode); socket_.close(); } void BoostConnection::write(const SafeByteArray& data) { - boost::lock_guard<boost::mutex> lock(writeMutex_); + std::lock_guard<std::mutex> lock(writeMutex_); if (!writing_) { writing_ = true; doWrite(data); @@ -120,7 +120,7 @@ void BoostConnection::handleConnectFinished(const boost::system::error_code& err void BoostConnection::doRead() { readBuffer_ = std::make_shared<SafeByteArray>(BUFFER_SIZE); - boost::lock_guard<boost::mutex> lock(readCloseMutex_); + std::lock_guard<std::mutex> lock(readCloseMutex_); socket_.async_read_some( boost::asio::buffer(*readBuffer_), boost::bind(&BoostConnection::handleSocketRead, shared_from_this(), boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred)); @@ -153,7 +153,7 @@ void BoostConnection::handleDataWritten(const boost::system::error_code& error) eventLoop->postEvent(boost::bind(boost::ref(onDisconnected), WriteError), shared_from_this()); } { - boost::lock_guard<boost::mutex> lock(writeMutex_); + std::lock_guard<std::mutex> lock(writeMutex_); if (writeQueue_.empty()) { writing_ = false; if (closeSocketAfterNextWrite_) { |