[Libreoffice-commits] core.git: Branch 'libreoffice-4-1' - fpicker/source

Michael Meeks michael.meeks at collabora.com
Wed Nov 20 12:52:00 PST 2013


 fpicker/source/win32/filepicker/asyncrequests.cxx |   45 ++++++++--------------
 fpicker/source/win32/filepicker/asyncrequests.hxx |    4 +
 2 files changed, 21 insertions(+), 28 deletions(-)

New commits:
commit 30df10db698c8d27358bece4e4865f8d16c012ff
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Wed Nov 20 20:05:56 2013 +0000

    fpicker: cleanup async requests, dung out comments.
    
    Change-Id: I016145d315ae1c4b5376e43583e2546a2b7f7b07
    (cherry picked from commit acc0fcd96c940e42da27bb58ba1c89ae5de5a5b8)
    Reviewed-on: https://gerrit.libreoffice.org/6736
    Reviewed-by: Kohei Yoshida <libreoffice at kohei.us>
    Tested-by: Kohei Yoshida <libreoffice at kohei.us>

diff --git a/fpicker/source/win32/filepicker/asyncrequests.cxx b/fpicker/source/win32/filepicker/asyncrequests.cxx
index 8ceea51..e3b43cb 100644
--- a/fpicker/source/win32/filepicker/asyncrequests.cxx
+++ b/fpicker/source/win32/filepicker/asyncrequests.cxx
@@ -25,9 +25,8 @@ namespace fpicker{
 namespace win32{
 namespace vista{
 
-//-----------------------------------------------------------------------------
-void lcl_sleep(::osl::Condition& aCondition   ,
-               ::sal_Int32       nMilliSeconds)
+static void lcl_sleep( ::osl::Condition& aCondition,
+                       ::sal_Int32       nMilliSeconds )
 {
     sal_uLong nAcquireCount = Application::ReleaseSolarMutex();
 
@@ -44,26 +43,23 @@ void lcl_sleep(::osl::Condition& aCondition   ,
     Application::AcquireSolarMutex( nAcquireCount );
 }
 
-//-----------------------------------------------------------------------------
-void Request::wait(::sal_Int32 nMilliSeconds)
+void Request::wait( ::sal_Int32 nMilliSeconds )
 {
-    lcl_sleep(m_aJoiner, nMilliSeconds);
+    lcl_sleep( m_aJoiner, nMilliSeconds );
 }
 
 void Request::waitProcessMessages()
 {
     SolarMutexGuard aGuard;
-    while (!m_aJoiner.check())
+    while ( !m_aJoiner.check() )
         Application::Yield();
 }
 
-//-----------------------------------------------------------------------------
 void Request::notify()
 {
     m_aJoiner.set();
 }
 
-//-----------------------------------------------------------------------------
 AsyncRequests::AsyncRequests(const RequestHandlerRef& rHandler)
     : ::cppu::BaseMutex(         )
     , ::osl::Thread    (         )
@@ -73,7 +69,6 @@ AsyncRequests::AsyncRequests(const RequestHandlerRef& rHandler)
 {
 }
 
-//-----------------------------------------------------------------------------
 AsyncRequests::~AsyncRequests()
 {
     // SYNCHRONIZED ->
@@ -85,6 +80,14 @@ AsyncRequests::~AsyncRequests()
     join();
 }
 
+void AsyncRequests::triggerJobExecution()
+{
+    if ( ! isRunning())
+        create();
+    else
+        maWait.set();
+}
+
 void AsyncRequests::triggerRequestProcessMessages (const RequestRef& rRequest)
 {
     // SYNCHRONIZED ->
@@ -93,13 +96,9 @@ void AsyncRequests::triggerRequestProcessMessages (const RequestRef& rRequest)
     aLock.clear();
     // <- SYNCHRONIZED
 
-    if ( ! isRunning())
-        create();
-
     rRequest->waitProcessMessages();
 }
 
-//-----------------------------------------------------------------------------
 void AsyncRequests::triggerRequestBlocked(const RequestRef& rRequest)
 {
     // SYNCHRONIZED ->
@@ -108,13 +107,11 @@ void AsyncRequests::triggerRequestBlocked(const RequestRef& rRequest)
     aLock.clear();
     // <- SYNCHRONIZED
 
-    if ( ! isRunning())
-        create();
+    triggerJobExecution();
 
     rRequest->wait(Request::WAIT_INFINITE);
 }
 
-//-----------------------------------------------------------------------------
 void AsyncRequests::triggerRequestNonBlocked(const RequestRef& rRequest)
 {
     // SYNCHRONIZED ->
@@ -123,11 +120,9 @@ void AsyncRequests::triggerRequestNonBlocked(const RequestRef& rRequest)
     aLock.clear();
     // <- SYNCHRONIZED
 
-    if ( ! isRunning())
-        create();
+    triggerJobExecution();
 }
 
-//-----------------------------------------------------------------------------
 void AsyncRequests::triggerRequestDirectly(const RequestRef& rRequest)
 {
     // SYNCHRONIZED ->
@@ -140,7 +135,6 @@ void AsyncRequests::triggerRequestDirectly(const RequestRef& rRequest)
         rHandler->doRequest(rRequest);
 }
 
-//-----------------------------------------------------------------------------
 void AsyncRequests::triggerRequestThreadAware(const RequestRef& rRequest,
                                                     ::sal_Int16  nWait   )
 {
@@ -156,10 +150,6 @@ void AsyncRequests::triggerRequestThreadAware(const RequestRef& rRequest,
         triggerRequestNonBlocked(rRequest);
 }
 
-//-----------------------------------------------------------------------------
-
-
-//-----------------------------------------------------------------------------
 void SAL_CALL AsyncRequests::run()
 {
     static const ::sal_Int32 TIME_TO_WAIT_FOR_NEW_REQUESTS = 250;
@@ -174,8 +164,6 @@ void SAL_CALL AsyncRequests::run()
     if (rHandler != NULL)
         rHandler->before();
 
-    ::osl::Condition aWait;
-
     while ( ! bFinished)
     {
         // SYNCHRONIZED ->
@@ -194,7 +182,8 @@ void SAL_CALL AsyncRequests::run()
 
         if (rRequest == NULL)
         {
-            lcl_sleep(aWait, TIME_TO_WAIT_FOR_NEW_REQUESTS);
+            lcl_sleep(maWait, TIME_TO_WAIT_FOR_NEW_REQUESTS);
+            maWait.reset();
             continue;
         }
 
diff --git a/fpicker/source/win32/filepicker/asyncrequests.hxx b/fpicker/source/win32/filepicker/asyncrequests.hxx
index 5ed844e..6653a6c 100644
--- a/fpicker/source/win32/filepicker/asyncrequests.hxx
+++ b/fpicker/source/win32/filepicker/asyncrequests.hxx
@@ -148,6 +148,9 @@ class AsyncRequests : private ::cppu::BaseMutex
             m_rHandler = rHandler;
         }
 
+        /// ensure the execution thread gets going.
+        void triggerJobExecution();
+
         //---------------------------------------------------------------------
         /** does nothing special / excepting to make sure our class wont be inline .-)
          */
@@ -194,6 +197,7 @@ class AsyncRequests : private ::cppu::BaseMutex
         ::sal_Bool m_bFinish;
         RequestHandlerRef m_rHandler;
         RequestQueue m_lRequests;
+        osl::Condition maWait;
 };
 
 } // namespace vista


More information about the Libreoffice-commits mailing list