[Libreoffice-commits] core.git: 3 commits - cppu/source filter/source io/source

Stephan Bergmann sbergman at redhat.com
Mon Aug 17 23:16:40 PDT 2015


 cppu/source/threadpool/jobqueue.cxx     |   22 ++++++---------------
 cppu/source/threadpool/jobqueue.hxx     |    5 +---
 cppu/source/threadpool/threadpool.cxx   |   16 +++++++--------
 cppu/source/threadpool/threadpool.hxx   |    7 ++++--
 filter/source/xsltfilter/XSLTFilter.cxx |   33 +++++++++++---------------------
 io/source/stm/opipe.cxx                 |   16 ++++++---------
 6 files changed, 41 insertions(+), 58 deletions(-)

New commits:
commit 6b7c23b3fb6175c04fcc3f1e12b34bedf5f4e5f8
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Aug 18 08:15:56 2015 +0200

    Some oslCondition -> osl::Condition
    
    Change-Id: Ib2c98db9ffd5871b6422c05f0230bbe27d1ba729

diff --git a/io/source/stm/opipe.cxx b/io/source/stm/opipe.cxx
index 4315a99..5c8af3e 100644
--- a/io/source/stm/opipe.cxx
+++ b/io/source/stm/opipe.cxx
@@ -116,7 +116,7 @@ private:
     bool m_bOutputStreamClosed;
     bool m_bInputStreamClosed;
 
-    oslCondition m_conditionBytesAvail;
+    osl::Condition m_conditionBytesAvail;
     Mutex     m_mutexAccess;
     I_FIFO      *m_pFIFO;
 };
@@ -131,12 +131,10 @@ OPipeImpl::OPipeImpl()
     m_bInputStreamClosed    = false;
 
     m_pFIFO = new MemFIFO;
-    m_conditionBytesAvail = osl_createCondition();
 }
 
 OPipeImpl::~OPipeImpl()
 {
-    osl_destroyCondition( m_conditionBytesAvail );
     delete m_pFIFO;
 }
 
@@ -164,7 +162,7 @@ sal_Int32 OPipeImpl::readBytes(Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRe
             if( nOccupiedBufferLen < nBytesToRead )
             {
                 // wait outside guarded section
-                osl_resetCondition( m_conditionBytesAvail );
+                m_conditionBytesAvail.reset();
             }
             else {
                 // necessary bytes are available
@@ -174,7 +172,7 @@ sal_Int32 OPipeImpl::readBytes(Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRe
         } // end guarded section
 
         // wait for new data outside guarded section!
-        osl_waitCondition( m_conditionBytesAvail , 0 );
+        m_conditionBytesAvail.wait();
     }
 }
 
@@ -208,7 +206,7 @@ sal_Int32 OPipeImpl::readSomeBytes(Sequence< sal_Int8 >& aData, sal_Int32 nMaxBy
             }
         }
 
-        osl_waitCondition( m_conditionBytesAvail , 0 );
+        m_conditionBytesAvail.wait();
     }
 }
 
@@ -268,7 +266,7 @@ void OPipeImpl::closeInput()
     m_pFIFO = 0;
 
     // readBytes may throw an exception
-    osl_setCondition( m_conditionBytesAvail );
+    m_conditionBytesAvail.set();
 
     setSuccessor( Reference< XConnectable > () );
     return;
@@ -334,7 +332,7 @@ void OPipeImpl::writeBytes(const Sequence< sal_Int8 >& aData)
     }
 
     // readBytes may check again if enough bytes are available
-    osl_setCondition( m_conditionBytesAvail );
+    m_conditionBytesAvail.set();
 }
 
 
@@ -355,7 +353,7 @@ void OPipeImpl::closeOutput()
     MutexGuard guard( m_mutexAccess );
 
     m_bOutputStreamClosed = true;
-    osl_setCondition( m_conditionBytesAvail );
+    m_conditionBytesAvail.set();
     setPredecessor( Reference < XConnectable > () );
     return;
 }
commit 88f12d9c7e58a3465f4d9a50fafb9e47fe67c537
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Aug 18 08:15:47 2015 +0200

    Some oslCondition -> osl::Condition
    
    Change-Id: I57c10b14cd8a5ab821516575768891b66f834ca6

diff --git a/filter/source/xsltfilter/XSLTFilter.cxx b/filter/source/xsltfilter/XSLTFilter.cxx
index 95a514c..c9ba40a 100644
--- a/filter/source/xsltfilter/XSLTFilter.cxx
+++ b/filter/source/xsltfilter/XSLTFilter.cxx
@@ -24,7 +24,7 @@
 #include <sax/tools/documenthandleradapter.hxx>
 
 #include <osl/time.h>
-#include <osl/conditn.h>
+#include <osl/conditn.hxx>
 #include <rtl/strbuf.hxx>
 #include <tools/urlobj.hxx>
 
@@ -110,7 +110,7 @@ namespace XSLT
 
         css::uno::Reference<xslt::XXSLTTransformer> m_tcontrol;
 
-        oslCondition m_cTransformed;
+        osl::Condition m_cTransformed;
         bool m_bTerminated;
         bool m_bError;
 
@@ -128,8 +128,6 @@ namespace XSLT
         // ctor...
         XSLTFilter(const css::uno::Reference<XComponentContext> &r);
 
-        virtual ~XSLTFilter();
-
         // XStreamListener
         virtual void SAL_CALL
         error(const Any& a) throw (RuntimeException, std::exception) SAL_OVERRIDE;
@@ -162,14 +160,7 @@ namespace XSLT
 
     XSLTFilter::XSLTFilter(const css::uno::Reference<XComponentContext> &r):
         m_xContext(r), m_bTerminated(false), m_bError(false)
-    {
-        m_cTransformed = osl_createCondition();
-    }
-
-    XSLTFilter::~XSLTFilter()
-    {
-        osl_destroyCondition(m_cTransformed);
-    }
+    {}
 
     void
     XSLTFilter::disposing(const EventObject&) throw (RuntimeException, std::exception)
@@ -233,7 +224,7 @@ namespace XSLT
     void
     XSLTFilter::started() throw (RuntimeException, std::exception)
     {
-        osl_resetCondition(m_cTransformed);
+        m_cTransformed.reset();
     }
     void
     XSLTFilter::error(const Any& a) throw (RuntimeException, std::exception)
@@ -244,18 +235,18 @@ namespace XSLT
             SAL_WARN("filter.xslt", "XSLTFilter::error was called: " << e.Message);
         }
         m_bError = true;
-        osl_setCondition(m_cTransformed);
+        m_cTransformed.set();
     }
     void
     XSLTFilter::closed() throw (RuntimeException, std::exception)
     {
-        osl_setCondition(m_cTransformed);
+        m_cTransformed.set();
     }
     void
     XSLTFilter::terminated() throw (RuntimeException, std::exception)
     {
         m_bTerminated = true;
-        osl_setCondition(m_cTransformed);
+        m_cTransformed.set();
     }
 
     OUString
@@ -370,8 +361,8 @@ namespace XSLT
                         // transform
                         m_tcontrol->start();
                         TimeValue timeout = { TRANSFORMATION_TIMEOUT_SEC, 0};
-                        oslConditionResult result(osl_waitCondition(m_cTransformed, &timeout));
-                        while (osl_cond_result_timeout == result) {
+                        osl::Condition::Result result(m_cTransformed.wait(&timeout));
+                        while (osl::Condition::result_timeout == result) {
                                 if (xInterActionHandler.is()) {
                                         Sequence<Any> excArgs(0);
                                         ::com::sun::star::ucb::InteractiveAugmentedIOException exc(
@@ -391,10 +382,10 @@ namespace XSLT
                                         xInterActionHandler->handle(xRequest);
                                         if (pAbort->wasSelected()) {
                                                 m_bError = true;
-                                                osl_setCondition(m_cTransformed);
+                                                m_cTransformed.set();
                                         }
                                 }
-                                result = osl_waitCondition(m_cTransformed, &timeout);
+                                result = m_cTransformed.wait(&timeout);
                         };
                         if (!m_bError) {
                                 xSaxParser->parseStream(aInput);
@@ -528,7 +519,7 @@ namespace XSLT
     {
         ExtendedDocumentHandlerAdapter::endDocument();
         // wait for the transformer to finish
-        osl_waitCondition(m_cTransformed, 0);
+        m_cTransformed.wait();
         m_tcontrol->terminate();
         if (!m_bError && !m_bTerminated)
             {
commit 2861d5bedcc1c4f57c69faf86c5b18ce15049d06
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Aug 18 08:15:29 2015 +0200

    Some oslCondition -> osl::Condition
    
    Change-Id: I86cfbefd1cb8b22fca659a158b8e31d5c991de7a

diff --git a/cppu/source/threadpool/jobqueue.cxx b/cppu/source/threadpool/jobqueue.cxx
index ec7b932..c0fdd62 100644
--- a/cppu/source/threadpool/jobqueue.cxx
+++ b/cppu/source/threadpool/jobqueue.cxx
@@ -28,19 +28,11 @@ namespace cppu_threadpool {
 
     JobQueue::JobQueue() :
         m_nToDo( 0 ),
-        m_bSuspended( false ),
-        m_cndWait( osl_createCondition() )
+        m_bSuspended( false )
     {
-        osl_resetCondition( m_cndWait );
         m_DisposedCallerAdmin = DisposedCallerAdmin::getInstance();
     }
 
-    JobQueue::~JobQueue()
-    {
-        osl_destroyCondition( m_cndWait );
-    }
-
-
     void JobQueue::add( void *pThreadSpecificData, RequestFun * doRequest )
     {
         MutexGuard guard( m_mutex );
@@ -48,7 +40,7 @@ namespace cppu_threadpool {
         m_lstJob.push_back( job );
         if( ! m_bSuspended )
         {
-            osl_setCondition( m_cndWait );
+            m_cndWait.set();
         }
         m_nToDo ++;
     }
@@ -78,7 +70,7 @@ namespace cppu_threadpool {
                 }
             }
 
-            osl_waitCondition( m_cndWait , 0 );
+            m_cndWait.wait();
 
             struct Job job={0,0};
             {
@@ -92,7 +84,7 @@ namespace cppu_threadpool {
                         && (m_lstCallstack.empty()
                             || m_lstCallstack.front() != 0) )
                     {
-                        osl_resetCondition( m_cndWait );
+                        m_cndWait.reset();
                     }
                     break;
                 }
@@ -106,7 +98,7 @@ namespace cppu_threadpool {
                 if( m_lstJob.empty()
                     && (m_lstCallstack.empty() || m_lstCallstack.front() != 0) )
                 {
-                    osl_resetCondition( m_cndWait );
+                    m_cndWait.reset();
                 }
             }
 
@@ -150,7 +142,7 @@ namespace cppu_threadpool {
         if( !m_lstCallstack.empty()  && ! m_lstCallstack.front() )
         {
             // The thread is waiting for a disposed pCallerId, let it go
-            osl_setCondition( m_cndWait );
+            m_cndWait.set();
         }
     }
 
@@ -166,7 +158,7 @@ namespace cppu_threadpool {
         m_bSuspended = false;
         if( ! m_lstJob.empty() )
         {
-            osl_setCondition( m_cndWait );
+            m_cndWait.set();
         }
     }
 
diff --git a/cppu/source/threadpool/jobqueue.hxx b/cppu/source/threadpool/jobqueue.hxx
index 1fffa64..3a55d6b 100644
--- a/cppu/source/threadpool/jobqueue.hxx
+++ b/cppu/source/threadpool/jobqueue.hxx
@@ -23,7 +23,7 @@
 #include <list>
 #include <sal/types.h>
 
-#include <osl/conditn.h>
+#include <osl/conditn.hxx>
 #include <osl/mutex.hxx>
 
 #include <boost/shared_ptr.hpp>
@@ -49,7 +49,6 @@ namespace cppu_threadpool
     {
     public:
         JobQueue();
-        ~JobQueue();
 
         void add( void *pThreadSpecificData, RequestFun * doRequest );
 
@@ -69,7 +68,7 @@ namespace cppu_threadpool
         CallStackList m_lstCallstack;
         sal_Int32 m_nToDo;
         bool m_bSuspended;
-        oslCondition m_cndWait;
+        osl::Condition m_cndWait;
         DisposedCallerAdminHolder m_DisposedCallerAdmin;
     };
 }
diff --git a/cppu/source/threadpool/threadpool.cxx b/cppu/source/threadpool/threadpool.cxx
index 965afce..6e7a2c0 100644
--- a/cppu/source/threadpool/threadpool.cxx
+++ b/cppu/source/threadpool/threadpool.cxx
@@ -39,6 +39,10 @@ using namespace ::rtl;
 
 namespace cppu_threadpool
 {
+    WaitingThread::WaitingThread(
+        rtl::Reference<ORequestThread> const & theThread): thread(theThread)
+    {}
+
     struct theDisposedCallerAdmin :
         public rtl::StaticWithInit< DisposedCallerAdminHolder, theDisposedCallerAdmin >
     {
@@ -138,9 +142,7 @@ namespace cppu_threadpool
      ******************/
     void ThreadPool::waitInPool( rtl::Reference< ORequestThread > const & pThread )
     {
-        struct WaitingThread waitingThread;
-        waitingThread.condition = osl_createCondition();
-        waitingThread.thread = pThread;
+        WaitingThread waitingThread(pThread);
         {
             MutexGuard guard( m_mutexWaitingThreadList );
             m_lstThreads.push_front( &waitingThread );
@@ -148,7 +150,7 @@ namespace cppu_threadpool
 
         // let the thread wait 2 seconds
         TimeValue time = { 2 , 0 };
-        osl_waitCondition( waitingThread.condition , &time );
+        waitingThread.condition.wait( &time );
 
         {
             MutexGuard guard ( m_mutexWaitingThreadList );
@@ -161,8 +163,6 @@ namespace cppu_threadpool
                 m_lstThreads.erase( ii );
             }
         }
-
-        osl_destroyCondition( waitingThread.condition );
     }
 
     void ThreadPool::joinWorkers()
@@ -174,7 +174,7 @@ namespace cppu_threadpool
                  ++ ii )
             {
                 // wake the threads up
-                osl_setCondition( (*ii)->condition );
+                (*ii)->condition.set();
             }
         }
         m_aThreadAdmin.join();
@@ -198,7 +198,7 @@ namespace cppu_threadpool
                 m_lstThreads.pop_back();
 
                 // let the thread go
-                osl_setCondition( pWaitingThread->condition );
+                pWaitingThread->condition.set();
                 return true;
             }
         }
diff --git a/cppu/source/threadpool/threadpool.hxx b/cppu/source/threadpool/threadpool.hxx
index dc17d64..b13dc0f 100644
--- a/cppu/source/threadpool/threadpool.hxx
+++ b/cppu/source/threadpool/threadpool.hxx
@@ -23,7 +23,7 @@
 #include <list>
 #include <unordered_map>
 
-#include <osl/conditn.h>
+#include <osl/conditn.hxx>
 
 #include <rtl/byteseq.hxx>
 #include <rtl/ref.hxx>
@@ -70,8 +70,11 @@ namespace cppu_threadpool {
 
     struct WaitingThread
     {
-        oslCondition condition;
+        osl::Condition condition;
         rtl::Reference< ORequestThread > thread;
+
+        explicit WaitingThread(
+            rtl::Reference<ORequestThread> const & theThread);
     };
 
     typedef ::std::list < struct ::cppu_threadpool::WaitingThread * > WaitingThreadList;


More information about the Libreoffice-commits mailing list