summaryrefslogtreecommitdiff
path: root/vcl/headless
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@suse.com>2011-09-30 15:46:24 +0100
committerMichael Meeks <michael.meeks@suse.com>2011-10-25 13:41:50 +0100
commit6297a9c4a117fcfd01ed99a54efba7e130805598 (patch)
tree962b2526d955654a7f5fe8f7f9e5d900e89109a0 /vcl/headless
parentef93683de1b1d1dbcd7e76df5033c4d117198667 (diff)
generic: share sal yield mutex properly
Diffstat (limited to 'vcl/headless')
-rw-r--r--vcl/headless/svpinst.cxx93
1 files changed, 3 insertions, 90 deletions
diff --git a/vcl/headless/svpinst.cxx b/vcl/headless/svpinst.cxx
index 182cf867529e..b3e868316a58 100644
--- a/vcl/headless/svpinst.cxx
+++ b/vcl/headless/svpinst.cxx
@@ -53,7 +53,7 @@ extern "C"
{
SAL_DLLPUBLIC_EXPORT SalInstance* create_SalInstance()
{
- SvpSalInstance* pInstance = new SvpSalInstance();
+ SvpSalInstance* pInstance = new SvpSalInstance( new SalYieldMutex() );
SalData* pSalData = new SalData();
pSalData->m_pInstance = pInstance;
SetSalData( pSalData );
@@ -77,8 +77,8 @@ bool SvpSalInstance::isFrameAlive( const SalFrame* pFrame ) const
SvpSalInstance* SvpSalInstance::s_pDefaultInstance = NULL;
-SvpSalInstance::SvpSalInstance() :
- SalGenericInstance( new SalYieldMutex() )
+SvpSalInstance::SvpSalInstance( SalYieldMutex *pMutex ) :
+ SalGenericInstance( pMutex )
{
m_aTimeout.tv_sec = 0;
m_aTimeout.tv_usec = 0;
@@ -304,51 +304,6 @@ SalBitmap* SvpSalInstance::CreateSalBitmap()
return new SvpSalBitmap();
}
-osl::SolarMutex* SvpSalInstance::GetYieldMutex()
-{
- return &m_aYieldMutex;
-}
-
-sal_uLong SvpSalInstance::ReleaseYieldMutex()
-{
- if ( m_aYieldMutex.GetThreadId() ==
- osl::Thread::getCurrentIdentifier() )
- {
- sal_uLong nCount = m_aYieldMutex.GetAcquireCount();
- sal_uLong n = nCount;
- while ( n )
- {
- m_aYieldMutex.release();
- n--;
- }
-
- return nCount;
- }
- else
- return 0;
-}
-
-void SvpSalInstance::AcquireYieldMutex( sal_uLong nCount )
-{
- while ( nCount )
- {
- m_aYieldMutex.acquire();
- nCount--;
- }
-}
-
-bool SvpSalInstance::CheckYieldMutex()
-{
- bool bRet = true;
-
- if ( m_aYieldMutex.GetThreadId() != ::osl::Thread::getCurrentIdentifier() )
- {
- bRet = false;
- }
-
- return bRet;
-}
-
void SvpSalInstance::Yield( bool bWait, bool bHandleAllCurrentEvents )
{
// first, check for already queued events.
@@ -453,48 +408,6 @@ void* SvpSalInstance::GetConnectionIdentifier( ConnectionIdentifierType& rReturn
return const_cast<char*>("");
}
-// -------------------------------------------------------------------------
-//
-// SalYieldMutex
-//
-// -------------------------------------------------------------------------
-
-SvpSalYieldMutex::SvpSalYieldMutex()
-{
- mnCount = 0;
- mnThreadId = 0;
-}
-
-void SvpSalYieldMutex::acquire()
-{
- SolarMutexObject::acquire();
- mnThreadId = osl::Thread::getCurrentIdentifier();
- mnCount++;
-}
-
-void SvpSalYieldMutex::release()
-{
- if ( mnThreadId == osl::Thread::getCurrentIdentifier() )
- {
- if ( mnCount == 1 )
- mnThreadId = 0;
- mnCount--;
- }
- SolarMutexObject::release();
-}
-
-sal_Bool SvpSalYieldMutex::tryToAcquire()
-{
- if ( SolarMutexObject::tryToAcquire() )
- {
- mnThreadId = osl::Thread::getCurrentIdentifier();
- mnCount++;
- return sal_True;
- }
- else
- return sal_False;
-}
-
// ---------------
// - SalTimer -
// ---------------