summaryrefslogtreecommitdiff
path: root/salhelper
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-04-01 21:25:49 +0100
committerCaolán McNamara <caolanm@redhat.com>2012-04-02 14:53:48 +0100
commit09bdea8900c5ce79df3e8f2b7fbeeed06a5b4111 (patch)
treebf8ccafec8f39df52a0b1c595e7c8a355630ac04 /salhelper
parent15f14ec79477142cf2bcb1484511b7bea6f1485b (diff)
remove static objects from static_initialization_and_destruction chain
Diffstat (limited to 'salhelper')
-rw-r--r--salhelper/source/timer.cxx24
1 files changed, 13 insertions, 11 deletions
diff --git a/salhelper/source/timer.cxx b/salhelper/source/timer.cxx
index aff006c95e8b..d7ad3edf37ee 100644
--- a/salhelper/source/timer.cxx
+++ b/salhelper/source/timer.cxx
@@ -32,6 +32,7 @@
#include <osl/thread.hxx>
#include <osl/conditn.hxx>
#include <osl/mutex.hxx>
+#include <rtl/instance.hxx>
using namespace salhelper;
@@ -77,9 +78,6 @@ protected:
// Signal the insertion of a timer
osl::Condition m_notEmpty;
- // Synchronize access to TimerManager
- static osl::Mutex m_Access;
-
// "Singleton Pattern"
static salhelper::TimerManager* m_pManager;
@@ -251,13 +249,17 @@ TTimeValue Timer::getRemainingTime() const
//
// Timer manager
//
+namespace
+{
+ // Synchronize access to TimerManager
+ struct theTimerManagerMutex : public rtl::Static< osl::Mutex, theTimerManagerMutex> {};
+}
-osl::Mutex salhelper::TimerManager::m_Access;
TimerManager* salhelper::TimerManager::m_pManager = NULL;
TimerManager::TimerManager()
{
- osl::MutexGuard Guard(&m_Access);
+ osl::MutexGuard Guard(theTimerManagerMutex::get());
OSL_ASSERT(m_pManager == 0);
@@ -273,7 +275,7 @@ TimerManager::TimerManager()
TimerManager::~TimerManager()
{
- osl::MutexGuard Guard(&m_Access);
+ osl::MutexGuard Guard(theTimerManagerMutex::get());
if ( m_pManager == this )
m_pManager = 0;
@@ -286,12 +288,12 @@ void TimerManager::onTerminated()
TimerManager* TimerManager::getTimerManager()
{
- osl::MutexGuard Guard(&m_Access);
+ osl::MutexGuard Guard(theTimerManagerMutex::get());
if (! m_pManager)
new TimerManager;
- return (m_pManager);
+ return m_pManager;
}
sal_Bool TimerManager::registerTimer(Timer* pTimer)
@@ -303,7 +305,7 @@ sal_Bool TimerManager::registerTimer(Timer* pTimer)
return sal_False;
}
- osl::MutexGuard Guard(&m_Lock);
+ osl::MutexGuard Guard(m_Lock);
// try to find one with equal or lower remaining time.
Timer** ppIter = &m_pHead;
@@ -345,7 +347,7 @@ sal_Bool TimerManager::unregisterTimer(Timer* pTimer)
}
// lock access
- osl::MutexGuard Guard(&m_Lock);
+ osl::MutexGuard Guard(m_Lock);
Timer** ppIter = &m_pHead;
@@ -373,7 +375,7 @@ sal_Bool TimerManager::lookupTimer(const Timer* pTimer)
}
// lock access
- osl::MutexGuard Guard(&m_Lock);
+ osl::MutexGuard Guard(m_Lock);
// check the list
for (Timer* pIter = m_pHead; pIter != 0; pIter= pIter->m_pNext)