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

Chris Sherlock chris.sherlock79 at gmail.com
Sat Mar 18 08:02:47 UTC 2017


 include/vcl/threadex.hxx       |    6 +++---
 vcl/source/helper/threadex.cxx |   26 +++++++++++++-------------
 2 files changed, 16 insertions(+), 16 deletions(-)

New commits:
commit 5ec1713ae5b177ae32970c7209cea55ee0041c5c
Author: Chris Sherlock <chris.sherlock79 at gmail.com>
Date:   Sat Mar 18 16:11:05 2017 +1100

    vcl: have SolarThreadExecutor use osl::Condition, not oslCondition
    
    Condition is deprecated already, but there is no need for the
    SolarThreadExecutor class to use the low-level C-API, when in fact there
    is a C++ fascade that calls on this via the C++ abstraction,
    osl::Condition.
    
    This will make it much easier to switch to using std::condition_variable
    in the future.
    
    Change-Id: I81e8530d42fe1451c4ca5bce998b13de0576bc4e
    Reviewed-on: https://gerrit.libreoffice.org/35386
    Reviewed-by: Chris Sherlock <chris.sherlock79 at gmail.com>
    Tested-by: Chris Sherlock <chris.sherlock79 at gmail.com>

diff --git a/include/vcl/threadex.hxx b/include/vcl/threadex.hxx
index 076974b0721e..6330a71bcc28 100644
--- a/include/vcl/threadex.hxx
+++ b/include/vcl/threadex.hxx
@@ -20,7 +20,7 @@
 #ifndef INCLUDED_VCL_THREADEX_HXX
 #define INCLUDED_VCL_THREADEX_HXX
 
-#include <osl/conditn.h>
+#include <osl/conditn.hxx>
 #include <osl/thread.h>
 #include <tools/link.hxx>
 #include <vcl/dllapi.h>
@@ -33,8 +33,8 @@ namespace vcl
 {
     class VCL_DLLPUBLIC SolarThreadExecutor
     {
-        oslCondition            m_aStart;
-        oslCondition            m_aFinish;
+        osl::Condition          m_aStart;
+        osl::Condition          m_aFinish;
         long                    m_nReturn;
         bool                    m_bTimeout;
 
diff --git a/vcl/source/helper/threadex.cxx b/vcl/source/helper/threadex.cxx
index 24b418e50702..7bc04082ab71 100644
--- a/vcl/source/helper/threadex.cxx
+++ b/vcl/source/helper/threadex.cxx
@@ -23,26 +23,24 @@
 using namespace vcl;
 
 SolarThreadExecutor::SolarThreadExecutor()
-    :m_nReturn( 0 )
+    :m_aStart()
+    ,m_aFinish()
+    ,m_nReturn( 0 )
     ,m_bTimeout( false )
 {
-    m_aStart = osl_createCondition();
-    m_aFinish = osl_createCondition();
 }
 
 SolarThreadExecutor::~SolarThreadExecutor()
 {
-    osl_destroyCondition( m_aStart );
-    osl_destroyCondition( m_aFinish );
 }
 
 IMPL_LINK_NOARG(SolarThreadExecutor, worker, void*, void)
 {
     if ( !m_bTimeout )
     {
-        osl_setCondition( m_aStart );
+        m_aStart.set();
         m_nReturn = doIt();
-        osl_setCondition( m_aFinish );
+        m_aFinish.set();
     }
 }
 
@@ -50,23 +48,25 @@ void SolarThreadExecutor::execute()
 {
     if( ::osl::Thread::getCurrentIdentifier() == Application::GetMainThreadIdentifier() )
     {
-        osl_setCondition( m_aStart );
+        m_aStart.set();
         m_nReturn = doIt();
-        osl_setCondition( m_aFinish );
+        m_aFinish.set();
     }
     else
     {
-        osl_resetCondition( m_aStart );
-        osl_resetCondition( m_aFinish );
+        m_aStart.reset();
+        m_aFinish.reset();
         SolarMutexReleaser aReleaser;
         ImplSVEvent * nEvent = Application::PostUserEvent( LINK( this, SolarThreadExecutor, worker ) );
-        if ( osl_cond_result_timeout == osl_waitCondition( m_aStart, nullptr ) )
+        if (m_aStart.wait() == osl::Condition::result_timeout)
         {
             m_bTimeout = true;
             Application::RemoveUserEvent( nEvent );
         }
         else
-            osl_waitCondition( m_aFinish, nullptr );
+        {
+            m_aFinish.wait();
+        }
     }
 }
 


More information about the Libreoffice-commits mailing list