binaryurp : use std::mutex in outgoingrequests

Change-Id: Ib0670af4596c5a40da27138d62b78df69bb77b9a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119121
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Arnaud Versini
2021-07-18 10:11:45 +02:00
committed by Noel Grandin
parent e0ba91b7e8
commit 3785f97ec1
2 changed files with 5 additions and 7 deletions

View File

@@ -23,7 +23,6 @@
#include <com/sun/star/uno/RuntimeException.hpp> #include <com/sun/star/uno/RuntimeException.hpp>
#include <rtl/byteseq.hxx> #include <rtl/byteseq.hxx>
#include <osl/mutex.hxx>
#include "lessoperators.hxx" #include "lessoperators.hxx"
#include "outgoingrequest.hxx" #include "outgoingrequest.hxx"
@@ -38,12 +37,12 @@ OutgoingRequests::~OutgoingRequests() {}
void OutgoingRequests::push( void OutgoingRequests::push(
rtl::ByteSequence const & tid, OutgoingRequest const & request) rtl::ByteSequence const & tid, OutgoingRequest const & request)
{ {
osl::MutexGuard g(mutex_); std::lock_guard g(mutex_);
map_[tid].push_back(request); map_[tid].push_back(request);
} }
OutgoingRequest OutgoingRequests::top(rtl::ByteSequence const & tid) { OutgoingRequest OutgoingRequests::top(rtl::ByteSequence const & tid) {
osl::MutexGuard g(mutex_); std::lock_guard g(mutex_);
Map::iterator i(map_.find(tid)); Map::iterator i(map_.find(tid));
if (i == map_.end()) { if (i == map_.end()) {
throw css::uno::RuntimeException( throw css::uno::RuntimeException(
@@ -54,7 +53,7 @@ OutgoingRequest OutgoingRequests::top(rtl::ByteSequence const & tid) {
} }
void OutgoingRequests::pop(rtl::ByteSequence const & tid) noexcept { void OutgoingRequests::pop(rtl::ByteSequence const & tid) noexcept {
osl::MutexGuard g(mutex_); std::lock_guard g(mutex_);
Map::iterator i(map_.find(tid)); Map::iterator i(map_.find(tid));
assert(i != map_.end()); assert(i != map_.end());
i->second.pop_back(); i->second.pop_back();

View File

@@ -22,10 +22,9 @@
#include <sal/config.h> #include <sal/config.h>
#include <map> #include <map>
#include <mutex>
#include <vector> #include <vector>
#include <osl/mutex.hxx>
namespace binaryurp namespace binaryurp
{ {
struct OutgoingRequest; struct OutgoingRequest;
@@ -56,7 +55,7 @@ private:
typedef std::map<rtl::ByteSequence, std::vector<OutgoingRequest>> Map; typedef std::map<rtl::ByteSequence, std::vector<OutgoingRequest>> Map;
osl::Mutex mutex_; std::mutex mutex_;
Map map_; Map map_;
}; };
} }