summaryrefslogtreecommitdiff
path: root/fpicker
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2013-11-20 20:05:56 +0000
committerKohei Yoshida <kohei.yoshida@collabora.com>2013-11-20 15:44:14 -0500
commitacc0fcd96c940e42da27bb58ba1c89ae5de5a5b8 (patch)
tree5d25e6551dec4a23b6e667db2b47668543e41a29 /fpicker
parent24b4610e10a539609a6679b598de7dc7957791c0 (diff)
fpicker: cleanup async requests, dung out comments.
Change-Id: I016145d315ae1c4b5376e43583e2546a2b7f7b07
Diffstat (limited to 'fpicker')
-rw-r--r--fpicker/source/win32/filepicker/asyncrequests.cxx45
-rw-r--r--fpicker/source/win32/filepicker/asyncrequests.hxx4
2 files changed, 21 insertions, 28 deletions
diff --git a/fpicker/source/win32/filepicker/asyncrequests.cxx b/fpicker/source/win32/filepicker/asyncrequests.cxx
index 8ceea5198186..e3b43cb65dec 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 5ed844ed609a..6653a6c7cb9c 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