binaryurp/source/bridge.cxx |   44 ++++++++++++++++++++++----------------------
 binaryurp/source/bridge.hxx |    3 ++-
 binaryurp/source/writer.cxx |    9 ++++-----
 binaryurp/source/writer.hxx |    4 ++--
 4 files changed, 30 insertions(+), 30 deletions(-)

New commits:
commit 34df7e2cb95385d513e9c74cda5178e3a68d27df
Author:     Arnaud Versini <arnaud.vers...@libreoffice.org>
AuthorDate: Thu Mar 24 12:56:28 2022 +0100
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Fri Mar 25 09:20:48 2022 +0100

    binaryurp: use more std::mutex
    
    Change-Id: I1d16c4cbf60e78323b74e7df049736bd0d0ab591
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132072
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/binaryurp/source/bridge.cxx b/binaryurp/source/bridge.cxx
index 3299cd0ed519..050ebec7403c 100644
--- a/binaryurp/source/bridge.cxx
+++ b/binaryurp/source/bridge.cxx
@@ -207,7 +207,7 @@ void Bridge::start() {
     rtl::Reference r(new Reader(this));
     rtl::Reference w(new Writer(this));
     {
-        osl::MutexGuard g(mutex_);
+        std::lock_guard g(mutex_);
         assert(
             state_ == STATE_INITIAL && threadPool_ == nullptr && !writer_.is() 
&&
             !reader_.is());
@@ -237,7 +237,7 @@ void Bridge::terminate(bool final) {
         bool joinW;
         Listeners ls;
         {
-            osl::ClearableMutexGuard g(mutex_);
+            std::unique_lock g(mutex_);
             switch (state_) {
             case STATE_INITIAL: // via ~Bridge -> dispose -> terminate
             case STATE_FINAL:
@@ -246,10 +246,10 @@ void Bridge::terminate(bool final) {
                 break;
             case STATE_TERMINATED:
                 if (final) {
-                    g.clear();
+                    g.unlock();
                     terminated_.wait();
                     {
-                        osl::MutexGuard g2(mutex_);
+                        std::lock_guard g2(mutex_);
                         tp = threadPool_;
                         threadPool_ = nullptr;
                         if (reader_.is()) {
@@ -309,7 +309,7 @@ void Bridge::terminate(bool final) {
         uno_threadpool_dispose(tp);
         Stubs s;
         {
-            osl::MutexGuard g(mutex_);
+            std::lock_guard g(mutex_);
             s.swap(stubs_);
         }
         for (auto & stub : s)
@@ -340,7 +340,7 @@ void Bridge::terminate(bool final) {
         uno_threadpool_destroy(tp);
     }
     {
-        osl::MutexGuard g(mutex_);
+        std::lock_guard g(mutex_);
         if (final) {
             threadPool_ = nullptr;
         }
@@ -361,14 +361,14 @@ BinaryAny Bridge::mapCppToBinaryAny(css::uno::Any const & 
cppAny) {
 }
 
 uno_ThreadPool Bridge::getThreadPool() {
-    osl::MutexGuard g(mutex_);
+    std::lock_guard g(mutex_);
     checkDisposed();
     assert(threadPool_ != nullptr);
     return threadPool_;
 }
 
 rtl::Reference< Writer > Bridge::getWriter() {
-    osl::MutexGuard g(mutex_);
+    std::lock_guard g(mutex_);
     checkDisposed();
     assert(writer_.is());
     return writer_;
@@ -392,7 +392,7 @@ css::uno::UnoInterfaceReference 
Bridge::registerIncomingInterface(
         } else {
             obj.set(new Proxy(this, oid, type), SAL_NO_ACQUIRE);
             {
-                osl::MutexGuard g(mutex_);
+                std::lock_guard g(mutex_);
                 assert(proxies_ < std::numeric_limits< std::size_t >::max());
                 ++proxies_;
             }
@@ -419,7 +419,7 @@ OUString Bridge::registerOutgoingInterface(
     if (!Proxy::isProxy(this, object, &oid)) {
         binaryUno_.get()->pExtEnv->getObjectIdentifier(
             binaryUno_.get()->pExtEnv, &oid.pData, object.get());
-        osl::MutexGuard g(mutex_);
+        std::lock_guard g(mutex_);
         Stubs::iterator i(stubs_.find(oid));
         Stub newStub;
         Stub * stub = i == stubs_.end() ? &newStub : &i->second;
@@ -458,7 +458,7 @@ css::uno::UnoInterfaceReference Bridge::findStub(
     OUString const & oid, css::uno::TypeDescription const & type)
 {
     assert(!oid.isEmpty() && type.is());
-    osl::MutexGuard g(mutex_);
+    std::lock_guard g(mutex_);
     Stubs::iterator i(stubs_.find(oid));
     if (i != stubs_.end()) {
         Stub::iterator j(i->second.find(type));
@@ -484,7 +484,7 @@ void Bridge::releaseStub(
     css::uno::UnoInterfaceReference obj;
     bool unused;
     {
-        osl::MutexGuard g(mutex_);
+        std::lock_guard g(mutex_);
         Stubs::iterator i(stubs_.find(oid));
         if (i == stubs_.end()) {
             throw css::uno::RuntimeException("URP: release unknown stub");
@@ -538,7 +538,7 @@ void Bridge::freeProxy(Proxy & proxy) {
     }
     bool unused;
     {
-        osl::MutexGuard g(mutex_);
+        std::lock_guard g(mutex_);
         assert(proxies_ > 0);
         --proxies_;
         unused = becameUnused();
@@ -547,7 +547,7 @@ void Bridge::freeProxy(Proxy & proxy) {
 }
 
 void Bridge::incrementCalls(bool normalCall) noexcept {
-    osl::MutexGuard g(mutex_);
+    std::lock_guard g(mutex_);
     assert(calls_ < std::numeric_limits< std::size_t >::max());
     ++calls_;
     normalCall_ |= normalCall;
@@ -556,7 +556,7 @@ void Bridge::incrementCalls(bool normalCall) noexcept {
 void Bridge::decrementCalls() {
     bool unused;
     {
-        osl::MutexGuard g(mutex_);
+        std::lock_guard g(mutex_);
         assert(calls_ > 0);
         --calls_;
         unused = becameUnused();
@@ -565,7 +565,7 @@ void Bridge::decrementCalls() {
 }
 
 void Bridge::incrementActiveCalls() noexcept {
-    osl::MutexGuard g(mutex_);
+    std::lock_guard g(mutex_);
     assert(
         activeCalls_ <= calls_ &&
         activeCalls_ < std::numeric_limits< std::size_t >::max());
@@ -574,7 +574,7 @@ void Bridge::incrementActiveCalls() noexcept {
 }
 
 void Bridge::decrementActiveCalls() noexcept {
-    osl::MutexGuard g(mutex_);
+    std::lock_guard g(mutex_);
     assert(activeCalls_ <= calls_ && activeCalls_ > 0);
     --activeCalls_;
     if (activeCalls_ == 0) {
@@ -824,19 +824,19 @@ bool Bridge::isProtocolPropertiesRequest(
 }
 
 void Bridge::setCurrentContextMode() {
-    osl::MutexGuard g(mutex_);
+    std::lock_guard g(mutex_);
     currentContextMode_ = true;
 }
 
 bool Bridge::isCurrentContextMode() {
-    osl::MutexGuard g(mutex_);
+    std::lock_guard g(mutex_);
     return currentContextMode_;
 }
 
 Bridge::~Bridge() {
 #if OSL_DEBUG_LEVEL > 0
     {
-        osl::MutexGuard g(mutex_);
+        std::lock_guard g(mutex_);
         SAL_WARN_IF(
             state_ == STATE_STARTED || state_ == STATE_TERMINATED, "binaryurp",
             "undisposed bridge \"" << name_ <<"\" in state " << state_
@@ -925,7 +925,7 @@ void Bridge::addEventListener(
 {
     assert(xListener.is());
     {
-        osl::MutexGuard g(mutex_);
+        std::lock_guard g(mutex_);
         assert(state_ != STATE_INITIAL);
         if (state_ == STATE_STARTED) {
             listeners_.push_back(xListener);
@@ -939,7 +939,7 @@ void Bridge::addEventListener(
 void Bridge::removeEventListener(
     css::uno::Reference< css::lang::XEventListener > const & aListener)
 {
-    osl::MutexGuard g(mutex_);
+    std::lock_guard g(mutex_);
     Listeners::iterator i(
         std::find(listeners_.begin(), listeners_.end(), aListener));
     if (i != listeners_.end()) {
diff --git a/binaryurp/source/bridge.hxx b/binaryurp/source/bridge.hxx
index fa9c2c5abdc3..2b5731b40497 100644
--- a/binaryurp/source/bridge.hxx
+++ b/binaryurp/source/bridge.hxx
@@ -23,6 +23,7 @@
 
 #include <cstddef>
 #include <map>
+#include <mutex>
 #include <vector>
 
 #include <com/sun/star/bridge/XBridge.hpp>
@@ -257,7 +258,7 @@ private:
         // decrementActiveCalls, without an intervening exception
     osl::Condition terminated_;
 
-    osl::Mutex mutex_;
+    std::mutex mutex_;
     State state_;
     Listeners listeners_;
     uno_ThreadPool threadPool_;
diff --git a/binaryurp/source/writer.cxx b/binaryurp/source/writer.cxx
index 250e251e8296..7749ce30c17d 100644
--- a/binaryurp/source/writer.cxx
+++ b/binaryurp/source/writer.cxx
@@ -31,7 +31,6 @@
 #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
 #include <com/sun/star/uno/XCurrentContext.hpp>
 #include <cppuhelper/exc_hlp.hxx>
-#include <osl/mutex.hxx>
 #include <sal/log.hxx>
 #include <uno/dispatcher.hxx>
 
@@ -108,7 +107,7 @@ void Writer::queueRequest(
     std::vector< BinaryAny >&& inArguments)
 {
     css::uno::UnoInterfaceReference cc(current_context::get());
-    osl::MutexGuard g(mutex_);
+    std::lock_guard g(mutex_);
     queue_.emplace_back(tid, oid, type, member, std::move(inArguments), cc);
     items_.set();
 }
@@ -119,7 +118,7 @@ void Writer::queueReply(
     bool exception, BinaryAny const & returnValue,
     std::vector< BinaryAny >&& outArguments, bool setCurrentContextMode)
 {
-    osl::MutexGuard g(mutex_);
+    std::lock_guard g(mutex_);
     queue_.emplace_back(
             tid, member, setter, exception, returnValue, 
std::move(outArguments),
             setCurrentContextMode);
@@ -135,7 +134,7 @@ void Writer::unblock() {
 
 void Writer::stop() {
     {
-        osl::MutexGuard g(mutex_);
+        std::lock_guard g(mutex_);
         stop_ = true;
     }
     unblocked_.set();
@@ -151,7 +150,7 @@ void Writer::execute() {
             items_.wait();
             Item item;
             {
-                osl::MutexGuard g(mutex_);
+                std::lock_guard g(mutex_);
                 if (stop_) {
                     return;
                 }
diff --git a/binaryurp/source/writer.hxx b/binaryurp/source/writer.hxx
index 42656000d0e3..ca3f8cccfec3 100644
--- a/binaryurp/source/writer.hxx
+++ b/binaryurp/source/writer.hxx
@@ -22,10 +22,10 @@
 #include <sal/config.h>
 
 #include <deque>
+#include <mutex>
 #include <vector>
 
 #include <osl/conditn.hxx>
-#include <osl/mutex.hxx>
 #include <rtl/byteseq.hxx>
 #include <rtl/ref.hxx>
 #include <rtl/ustring.hxx>
@@ -141,7 +141,7 @@ private:
     osl::Condition unblocked_;
     osl::Condition items_;
 
-    osl::Mutex mutex_;
+    std::mutex mutex_;
     std::deque< Item > queue_;
     bool stop_;
 };

Reply via email to