tdf#43157 - salhelper: timer.cxx change OSL_ASSERT to assert
There are a number of instances where OSL_ASSERT are just not necessary. Also, we need to change from testing if something is/is not equal to nullptr and just use the simpler form. Change-Id: I7e0b7deb12f0189030f66dd14ab23287341c82b7 Reviewed-on: https://gerrit.libreoffice.org/38507 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Chris Sherlock <chris.sherlock79@gmail.com>
This commit is contained in:
@@ -19,7 +19,6 @@
|
||||
#include <salhelper/timer.hxx>
|
||||
#include <salhelper/simplereferenceobject.hxx>
|
||||
|
||||
#include <osl/diagnose.h>
|
||||
#include <osl/thread.hxx>
|
||||
#include <osl/conditn.hxx>
|
||||
#include <osl/mutex.hxx>
|
||||
@@ -106,38 +105,27 @@ void Timer::start()
|
||||
|
||||
TimerManager *pManager = TimerManager::getTimerManager();
|
||||
|
||||
OSL_ASSERT(pManager);
|
||||
|
||||
if (pManager != nullptr)
|
||||
{
|
||||
if (pManager)
|
||||
pManager->registerTimer(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Timer::stop()
|
||||
{
|
||||
TimerManager *pManager = TimerManager::getTimerManager();
|
||||
|
||||
OSL_ASSERT(pManager);
|
||||
|
||||
if (pManager != nullptr)
|
||||
{
|
||||
if (pManager)
|
||||
pManager->unregisterTimer(this);
|
||||
}
|
||||
}
|
||||
|
||||
sal_Bool Timer::isTicking() const
|
||||
{
|
||||
TimerManager *pManager = TimerManager::getTimerManager();
|
||||
|
||||
OSL_ASSERT(pManager);
|
||||
|
||||
if (pManager)
|
||||
return pManager->lookupTimer(this);
|
||||
else
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
sal_Bool Timer::isExpired() const
|
||||
@@ -151,17 +139,11 @@ sal_Bool Timer::isExpired() const
|
||||
|
||||
sal_Bool Timer::expiresBefore(const Timer* pTimer) const
|
||||
{
|
||||
OSL_ASSERT(pTimer);
|
||||
|
||||
if (pTimer != nullptr)
|
||||
{
|
||||
if (pTimer)
|
||||
return m_aExpired < pTimer->m_aExpired;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void Timer::setAbsoluteTime(const TTimeValue& Time)
|
||||
{
|
||||
@@ -242,12 +224,10 @@ TimerManager::TimerManager()
|
||||
{
|
||||
osl::MutexGuard Guard(theTimerManagerMutex::get());
|
||||
|
||||
OSL_ASSERT(m_pManager == nullptr);
|
||||
assert(m_pManager == nullptr);
|
||||
|
||||
m_pManager = this;
|
||||
|
||||
m_pHead= nullptr;
|
||||
|
||||
m_notEmpty.reset();
|
||||
|
||||
// start thread
|
||||
@@ -279,12 +259,8 @@ TimerManager* TimerManager::getTimerManager()
|
||||
|
||||
void TimerManager::registerTimer(Timer* pTimer)
|
||||
{
|
||||
OSL_ASSERT(pTimer);
|
||||
|
||||
if ( pTimer == nullptr )
|
||||
{
|
||||
if (!pTimer)
|
||||
return;
|
||||
}
|
||||
|
||||
osl::MutexGuard Guard(m_Lock);
|
||||
|
||||
@@ -318,12 +294,8 @@ void TimerManager::registerTimer(Timer* pTimer)
|
||||
|
||||
void TimerManager::unregisterTimer(Timer* pTimer)
|
||||
{
|
||||
OSL_ASSERT(pTimer);
|
||||
|
||||
if ( pTimer == nullptr )
|
||||
{
|
||||
if (!pTimer)
|
||||
return;
|
||||
}
|
||||
|
||||
// lock access
|
||||
osl::MutexGuard Guard(m_Lock);
|
||||
@@ -344,12 +316,8 @@ void TimerManager::unregisterTimer(Timer* pTimer)
|
||||
|
||||
bool TimerManager::lookupTimer(const Timer* pTimer)
|
||||
{
|
||||
OSL_ASSERT(pTimer);
|
||||
|
||||
if ( pTimer == nullptr )
|
||||
{
|
||||
if (!pTimer)
|
||||
return false;
|
||||
}
|
||||
|
||||
// lock access
|
||||
osl::MutexGuard Guard(m_Lock);
|
||||
@@ -358,20 +326,17 @@ bool TimerManager::lookupTimer(const Timer* pTimer)
|
||||
for (Timer* pIter = m_pHead; pIter != nullptr; pIter= pIter->m_pNext)
|
||||
{
|
||||
if (pIter == pTimer)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void TimerManager::checkForTimeout()
|
||||
{
|
||||
|
||||
m_Lock.acquire();
|
||||
|
||||
if ( m_pHead == nullptr )
|
||||
if (!m_pHead)
|
||||
{
|
||||
m_Lock.release();
|
||||
return;
|
||||
|
Reference in New Issue
Block a user