[Libreoffice-commits] core.git: include/vcl vcl/inc vcl/source

Stephan Bergmann sbergman at redhat.com
Wed Aug 9 16:11:04 UTC 2017


 include/vcl/scheduler.hxx    |    2 +-
 vcl/inc/schedulerimpl.hxx    |   10 ++--------
 vcl/source/app/scheduler.cxx |   15 +++++++++------
 vcl/source/app/svapp.cxx     |    6 ++----
 4 files changed, 14 insertions(+), 19 deletions(-)

New commits:
commit dab0835c2f37e322cc64e63824bd4ec8f54c5b1d
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Aug 9 18:09:08 2017 +0200

    osl::Mutex::acquire can effectively only fail upon programming errors
    
    ...so simplify the design a bit here (and there was no meaningful failure-
    handling code, anyway)
    
    Change-Id: I34bb3a7b5fc56f2213a4d22438f0733e1b65fe4b

diff --git a/include/vcl/scheduler.hxx b/include/vcl/scheduler.hxx
index 1196466cdb22..5c9d8f0d0d6e 100644
--- a/include/vcl/scheduler.hxx
+++ b/include/vcl/scheduler.hxx
@@ -40,7 +40,7 @@ class VCL_DLLPUBLIC Scheduler final
 
     static void ImplStartTimer ( sal_uInt64 nMS, bool bForce, sal_uInt64 nTime );
 
-    static bool Lock( sal_uInt32 nLockCount = 1 );
+    static void Lock( sal_uInt32 nLockCount = 1 );
     static sal_uInt32 Unlock( bool bUnlockAll = false );
 
 public:
diff --git a/vcl/inc/schedulerimpl.hxx b/vcl/inc/schedulerimpl.hxx
index df10fc930bda..004122932965 100644
--- a/vcl/inc/schedulerimpl.hxx
+++ b/vcl/inc/schedulerimpl.hxx
@@ -45,27 +45,21 @@ class SchedulerMutex final
 public:
     SchedulerMutex() : mnLockDepth( 0 ) {}
 
-    bool acquire( sal_uInt32 nLockCount = 1 );
+    void acquire( sal_uInt32 nLockCount = 1 );
     sal_uInt32 release( bool bUnlockAll = false );
     sal_uInt32 lockDepth() const { return mnLockDepth; }
 };
 
 class SchedulerGuard final
 {
-    bool mbLocked;
-
 public:
     SchedulerGuard()
-        : mbLocked( false )
     {
-        mbLocked = Scheduler::Lock();
-        assert( mbLocked );
+        Scheduler::Lock();
     }
 
     ~SchedulerGuard()
     {
-        if ( !mbLocked )
-            return;
         Scheduler::Unlock();
     }
 };
diff --git a/vcl/source/app/scheduler.cxx b/vcl/source/app/scheduler.cxx
index b08444db93d3..72653436e1c6 100644
--- a/vcl/source/app/scheduler.cxx
+++ b/vcl/source/app/scheduler.cxx
@@ -17,6 +17,10 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
+
+#include <cassert>
+
 #include <svdata.hxx>
 #include <tools/time.hxx>
 #include <vcl/scheduler.hxx>
@@ -118,14 +122,13 @@ void Scheduler::ImplDeInitScheduler()
     rSchedCtx.mnTimerPeriod        = InfiniteTimeoutMs;
 }
 
-bool SchedulerMutex::acquire( sal_uInt32 nLockCount )
+void SchedulerMutex::acquire( sal_uInt32 nLockCount )
 {
     for (sal_uInt32 i = 0; i != nLockCount; ++i) {
-        if ( !maMutex.acquire() )
-            return false;
+        bool ok = maMutex.acquire();
+        assert(ok); (void) ok;
         ++mnLockDepth;
     }
-    return true;
 }
 
 sal_uInt32 SchedulerMutex::release( bool bUnlockAll )
@@ -139,11 +142,11 @@ sal_uInt32 SchedulerMutex::release( bool bUnlockAll )
     return nLockCount;
 }
 
-bool Scheduler::Lock( sal_uInt32 nLockCount )
+void Scheduler::Lock( sal_uInt32 nLockCount )
 {
     ImplSVData* pSVData = ImplGetSVData();
     assert( pSVData != nullptr );
-    return pSVData->maSchedCtx.maMutex.acquire( nLockCount );
+    pSVData->maSchedCtx.maMutex.acquire( nLockCount );
 }
 
 sal_uInt32 Scheduler::Unlock( bool bUnlockAll )
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index 5d32d0532eeb..c4b900754f6f 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -499,9 +499,8 @@ void Scheduler::ProcessEventsToIdle()
 #if OSL_DEBUG_LEVEL > 0
     const ImplSVData* pSVData = ImplGetSVData();
     bool bIsMainThread = pSVData->mpDefInst->IsMainThread();
-    bool mbLocked = false;
     if ( bIsMainThread )
-        mbLocked = Scheduler::Lock();
+        Scheduler::Lock();
 #endif
     while( Application::Reschedule( true ) )
     {
@@ -532,8 +531,7 @@ void Scheduler::ProcessEventsToIdle()
         pSchedulerData = pSchedulerData->mpNext;
     }
     assert( !bAnyIdle );
-    if ( mbLocked )
-        Scheduler::Unlock();
+    Scheduler::Unlock();
 #endif
 }
 


More information about the Libreoffice-commits mailing list