mirror of https://github.com/Icinga/icinga2.git
Use Timer::Create() instead of new Timer()
git ls-files -z |xargs -0 perl -pi -e 's/\bnew Timer\b/Timer::Create/g' ex. in Timer::Create() itself.
This commit is contained in:
parent
bb1f574b69
commit
21b68455ce
|
@ -232,7 +232,7 @@ static void TypeInfoTimerHandler()
|
|||
}
|
||||
|
||||
INITIALIZE_ONCE([]() {
|
||||
l_ObjectCountTimer = new Timer();
|
||||
l_ObjectCountTimer = Timer::Create();
|
||||
l_ObjectCountTimer->SetInterval(10);
|
||||
l_ObjectCountTimer->OnTimerExpired.connect([](const Timer * const&) { TypeInfoTimerHandler(); });
|
||||
l_ObjectCountTimer->Start();
|
||||
|
|
|
@ -58,7 +58,7 @@ void StreamLogger::BindStream(std::ostream *stream, bool ownsStream)
|
|||
m_OwnsStream = ownsStream;
|
||||
|
||||
if (!m_FlushLogTimer) {
|
||||
m_FlushLogTimer = new Timer();
|
||||
m_FlushLogTimer = Timer::Create();
|
||||
m_FlushLogTimer->SetInterval(1);
|
||||
m_FlushLogTimer->OnTimerExpired.connect([this](const Timer * const&) { FlushLogTimerHandler(); });
|
||||
m_FlushLogTimer->Start();
|
||||
|
|
|
@ -21,7 +21,7 @@ WorkQueue::WorkQueue(size_t maxItems, int threadCount, LogSeverity statsLogLevel
|
|||
/* Initialize logger. */
|
||||
m_StatusTimerTimeout = Utility::GetTime();
|
||||
|
||||
m_StatusTimer = new Timer();
|
||||
m_StatusTimer = Timer::Create();
|
||||
m_StatusTimer->SetInterval(10);
|
||||
m_StatusTimer->OnTimerExpired.connect([this](const Timer * const&) { StatusTimerHandler(); });
|
||||
m_StatusTimer->Start();
|
||||
|
|
|
@ -67,7 +67,7 @@ void CheckerComponent::Start(bool runtimeCreated)
|
|||
|
||||
m_Thread = std::thread([this]() { CheckThreadProc(); });
|
||||
|
||||
m_ResultTimer = new Timer();
|
||||
m_ResultTimer = Timer::Create();
|
||||
m_ResultTimer->SetInterval(5);
|
||||
m_ResultTimer->OnTimerExpired.connect([this](const Timer * const&) { ResultTimerHandler(); });
|
||||
m_ResultTimer->Start();
|
||||
|
|
|
@ -69,7 +69,7 @@ void CompatLogger::Start(bool runtimeCreated)
|
|||
ExternalCommandHandler(command, arguments);
|
||||
});
|
||||
|
||||
m_RotationTimer = new Timer();
|
||||
m_RotationTimer = Timer::Create();
|
||||
m_RotationTimer->OnTimerExpired.connect([this](const Timer * const&) { RotationTimerHandler(); });
|
||||
m_RotationTimer->Start();
|
||||
|
||||
|
|
|
@ -83,14 +83,14 @@ void DbConnection::Resume()
|
|||
Log(LogInformation, "DbConnection")
|
||||
<< "Resuming IDO connection: " << GetName();
|
||||
|
||||
m_CleanUpTimer = new Timer();
|
||||
m_CleanUpTimer = Timer::Create();
|
||||
m_CleanUpTimer->SetInterval(60);
|
||||
m_CleanUpTimer->OnTimerExpired.connect([this](const Timer * const&) { CleanUpHandler(); });
|
||||
m_CleanUpTimer->Start();
|
||||
|
||||
m_LogStatsTimeout = 0;
|
||||
|
||||
m_LogStatsTimer = new Timer();
|
||||
m_LogStatsTimer = Timer::Create();
|
||||
m_LogStatsTimer->SetInterval(10);
|
||||
m_LogStatsTimer->OnTimerExpired.connect([this](const Timer * const&) { LogStatsHandler(); });
|
||||
m_LogStatsTimer->Start();
|
||||
|
@ -135,7 +135,7 @@ void DbConnection::Pause()
|
|||
|
||||
void DbConnection::InitializeDbTimer()
|
||||
{
|
||||
m_ProgramStatusTimer = new Timer();
|
||||
m_ProgramStatusTimer = Timer::Create();
|
||||
m_ProgramStatusTimer->SetInterval(10);
|
||||
m_ProgramStatusTimer->OnTimerExpired.connect([](const Timer * const&) { UpdateProgramStatus(); });
|
||||
m_ProgramStatusTimer->Start();
|
||||
|
|
|
@ -85,12 +85,12 @@ void IdoMysqlConnection::Resume()
|
|||
/* Immediately try to connect on Resume() without timer. */
|
||||
m_QueryQueue.Enqueue([this]() { Reconnect(); }, PriorityImmediate);
|
||||
|
||||
m_TxTimer = new Timer();
|
||||
m_TxTimer = Timer::Create();
|
||||
m_TxTimer->SetInterval(1);
|
||||
m_TxTimer->OnTimerExpired.connect([this](const Timer * const&) { NewTransaction(); });
|
||||
m_TxTimer->Start();
|
||||
|
||||
m_ReconnectTimer = new Timer();
|
||||
m_ReconnectTimer = Timer::Create();
|
||||
m_ReconnectTimer->SetInterval(10);
|
||||
m_ReconnectTimer->OnTimerExpired.connect([this](const Timer * const&){ ReconnectTimerHandler(); });
|
||||
m_ReconnectTimer->Start();
|
||||
|
|
|
@ -92,12 +92,12 @@ void IdoPgsqlConnection::Resume()
|
|||
/* Immediately try to connect on Resume() without timer. */
|
||||
m_QueryQueue.Enqueue([this]() { Reconnect(); }, PriorityImmediate);
|
||||
|
||||
m_TxTimer = new Timer();
|
||||
m_TxTimer = Timer::Create();
|
||||
m_TxTimer->SetInterval(1);
|
||||
m_TxTimer->OnTimerExpired.connect([this](const Timer * const&) { NewTransaction(); });
|
||||
m_TxTimer->Start();
|
||||
|
||||
m_ReconnectTimer = new Timer();
|
||||
m_ReconnectTimer = Timer::Create();
|
||||
m_ReconnectTimer->SetInterval(10);
|
||||
m_ReconnectTimer->OnTimerExpired.connect([this](const Timer * const&) { ReconnectTimerHandler(); });
|
||||
m_ReconnectTimer->Start();
|
||||
|
|
|
@ -101,12 +101,12 @@ void Checkable::Start(bool runtimeCreated)
|
|||
static boost::once_flag once = BOOST_ONCE_INIT;
|
||||
|
||||
boost::call_once(once, []() {
|
||||
l_CheckablesFireSuppressedNotifications = new Timer();
|
||||
l_CheckablesFireSuppressedNotifications = Timer::Create();
|
||||
l_CheckablesFireSuppressedNotifications->SetInterval(5);
|
||||
l_CheckablesFireSuppressedNotifications->OnTimerExpired.connect(&Checkable::FireSuppressedNotificationsTimer);
|
||||
l_CheckablesFireSuppressedNotifications->Start();
|
||||
|
||||
l_CleanDeadlinedExecutions = new Timer();
|
||||
l_CleanDeadlinedExecutions = Timer::Create();
|
||||
l_CleanDeadlinedExecutions->SetInterval(300);
|
||||
l_CleanDeadlinedExecutions->OnTimerExpired.connect(&Checkable::CleanDeadlinedExecutions);
|
||||
l_CleanDeadlinedExecutions->Start();
|
||||
|
|
|
@ -54,7 +54,7 @@ void ClusterEvents::EnqueueCheck(const MessageOrigin::Ptr& origin, const Diction
|
|||
static boost::once_flag once = BOOST_ONCE_INIT;
|
||||
|
||||
boost::call_once(once, []() {
|
||||
m_LogTimer = new Timer();
|
||||
m_LogTimer = Timer::Create();
|
||||
m_LogTimer->SetInterval(10);
|
||||
m_LogTimer->OnTimerExpired.connect([](const Timer * const&) { LogRemoteCheckQueueInformation(); });
|
||||
m_LogTimer->Start();
|
||||
|
|
|
@ -81,7 +81,7 @@ void Comment::Start(bool runtimeCreated)
|
|||
static boost::once_flag once = BOOST_ONCE_INIT;
|
||||
|
||||
boost::call_once(once, [this]() {
|
||||
l_CommentsExpireTimer = new Timer();
|
||||
l_CommentsExpireTimer = Timer::Create();
|
||||
l_CommentsExpireTimer->SetInterval(60);
|
||||
l_CommentsExpireTimer->OnTimerExpired.connect([](const Timer * const&) { CommentsExpireTimerHandler(); });
|
||||
l_CommentsExpireTimer->Start();
|
||||
|
|
|
@ -93,12 +93,12 @@ void Downtime::Start(bool runtimeCreated)
|
|||
static boost::once_flag once = BOOST_ONCE_INIT;
|
||||
|
||||
boost::call_once(once, [this]() {
|
||||
l_DowntimesStartTimer = new Timer();
|
||||
l_DowntimesStartTimer = Timer::Create();
|
||||
l_DowntimesStartTimer->SetInterval(5);
|
||||
l_DowntimesStartTimer->OnTimerExpired.connect([](const Timer * const&){ DowntimesStartTimerHandler(); });
|
||||
l_DowntimesStartTimer->Start();
|
||||
|
||||
l_DowntimesExpireTimer = new Timer();
|
||||
l_DowntimesExpireTimer = Timer::Create();
|
||||
l_DowntimesExpireTimer->SetInterval(60);
|
||||
l_DowntimesExpireTimer->OnTimerExpired.connect([](const Timer * const&) { DowntimesExpireTimerHandler(); });
|
||||
l_DowntimesExpireTimer->Start();
|
||||
|
|
|
@ -104,7 +104,7 @@ int IcingaApplication::Main()
|
|||
Log(LogDebug, "IcingaApplication", "In IcingaApplication::Main()");
|
||||
|
||||
/* periodically dump the program state */
|
||||
l_RetentionTimer = new Timer();
|
||||
l_RetentionTimer = Timer::Create();
|
||||
l_RetentionTimer->SetInterval(300);
|
||||
l_RetentionTimer->OnTimerExpired.connect([this](const Timer * const&) { DumpProgramState(); });
|
||||
l_RetentionTimer->Start();
|
||||
|
|
|
@ -78,7 +78,7 @@ void ScheduledDowntime::Start(bool runtimeCreated)
|
|||
static boost::once_flag once = BOOST_ONCE_INIT;
|
||||
|
||||
boost::call_once(once, [this]() {
|
||||
l_Timer = new Timer();
|
||||
l_Timer = Timer::Create();
|
||||
l_Timer->SetInterval(60);
|
||||
l_Timer->OnTimerExpired.connect([](const Timer * const&) { TimerProc(); });
|
||||
l_Timer->Start();
|
||||
|
|
|
@ -24,7 +24,7 @@ void TimePeriod::Start(bool runtimeCreated)
|
|||
static boost::once_flag once = BOOST_ONCE_INIT;
|
||||
|
||||
boost::call_once(once, [this]() {
|
||||
l_UpdateTimer = new Timer();
|
||||
l_UpdateTimer = Timer::Create();
|
||||
l_UpdateTimer->SetInterval(300);
|
||||
l_UpdateTimer->OnTimerExpired.connect([](const Timer * const&) { UpdateTimerHandler(); });
|
||||
l_UpdateTimer->Start();
|
||||
|
|
|
@ -115,7 +115,7 @@ void IcingaDB::Start(bool runtimeCreated)
|
|||
});
|
||||
m_Rcon->Start();
|
||||
|
||||
m_StatsTimer = new Timer();
|
||||
m_StatsTimer = Timer::Create();
|
||||
m_StatsTimer->SetInterval(1);
|
||||
m_StatsTimer->OnTimerExpired.connect([this](const Timer * const&) { PublishStatsTimerHandler(); });
|
||||
m_StatsTimer->Start();
|
||||
|
|
|
@ -44,7 +44,7 @@ void NotificationComponent::Start(bool runtimeCreated)
|
|||
SendNotificationsHandler(checkable, type, cr, author, text);
|
||||
});
|
||||
|
||||
m_NotificationTimer = new Timer();
|
||||
m_NotificationTimer = Timer::Create();
|
||||
m_NotificationTimer->SetInterval(5);
|
||||
m_NotificationTimer->OnTimerExpired.connect([this](const Timer * const&) { NotificationTimerHandler(); });
|
||||
m_NotificationTimer->Start();
|
||||
|
|
|
@ -88,7 +88,7 @@ void ElasticsearchWriter::Resume()
|
|||
m_WorkQueue.SetExceptionCallback([this](boost::exception_ptr exp) { ExceptionHandler(std::move(exp)); });
|
||||
|
||||
/* Setup timer for periodically flushing m_DataBuffer */
|
||||
m_FlushTimer = new Timer();
|
||||
m_FlushTimer = Timer::Create();
|
||||
m_FlushTimer->SetInterval(GetFlushInterval());
|
||||
m_FlushTimer->OnTimerExpired.connect([this](const Timer * const&) { FlushTimeout(); });
|
||||
m_FlushTimer->Start();
|
||||
|
|
|
@ -83,7 +83,7 @@ void GelfWriter::Resume()
|
|||
m_WorkQueue.SetExceptionCallback([this](boost::exception_ptr exp) { ExceptionHandler(std::move(exp)); });
|
||||
|
||||
/* Timer for reconnecting */
|
||||
m_ReconnectTimer = new Timer();
|
||||
m_ReconnectTimer = Timer::Create();
|
||||
m_ReconnectTimer->SetInterval(10);
|
||||
m_ReconnectTimer->OnTimerExpired.connect([this](const Timer * const&) { ReconnectTimerHandler(); });
|
||||
m_ReconnectTimer->Start();
|
||||
|
|
|
@ -88,7 +88,7 @@ void GraphiteWriter::Resume()
|
|||
m_WorkQueue.SetExceptionCallback([this](boost::exception_ptr exp) { ExceptionHandler(std::move(exp)); });
|
||||
|
||||
/* Timer for reconnecting */
|
||||
m_ReconnectTimer = new Timer();
|
||||
m_ReconnectTimer = Timer::Create();
|
||||
m_ReconnectTimer->SetInterval(10);
|
||||
m_ReconnectTimer->OnTimerExpired.connect([this](const Timer * const&) { ReconnectTimerHandler(); });
|
||||
m_ReconnectTimer->Start();
|
||||
|
|
|
@ -91,7 +91,7 @@ void InfluxdbCommonWriter::Resume()
|
|||
m_WorkQueue.SetExceptionCallback([this](boost::exception_ptr exp) { ExceptionHandler(std::move(exp)); });
|
||||
|
||||
/* Setup timer for periodically flushing m_DataBuffer */
|
||||
m_FlushTimer = new Timer();
|
||||
m_FlushTimer = Timer::Create();
|
||||
m_FlushTimer->SetInterval(GetFlushInterval());
|
||||
m_FlushTimer->OnTimerExpired.connect([this](const Timer * const&) { FlushTimeout(); });
|
||||
m_FlushTimer->Start();
|
||||
|
|
|
@ -75,7 +75,7 @@ void OpenTsdbWriter::Resume()
|
|||
|
||||
ReadConfigTemplate(m_ServiceConfigTemplate, m_HostConfigTemplate);
|
||||
|
||||
m_ReconnectTimer = new Timer();
|
||||
m_ReconnectTimer = Timer::Create();
|
||||
m_ReconnectTimer->SetInterval(10);
|
||||
m_ReconnectTimer->OnTimerExpired.connect([this](const Timer * const&) { ReconnectTimerHandler(); });
|
||||
m_ReconnectTimer->Start();
|
||||
|
|
|
@ -58,7 +58,7 @@ void PerfdataWriter::Resume()
|
|||
CheckResultHandler(checkable, cr);
|
||||
});
|
||||
|
||||
m_RotationTimer = new Timer();
|
||||
m_RotationTimer = Timer::Create();
|
||||
m_RotationTimer->OnTimerExpired.connect([this](const Timer * const&) { RotationTimerHandler(); });
|
||||
m_RotationTimer->SetInterval(GetRotationInterval());
|
||||
m_RotationTimer->Start();
|
||||
|
|
|
@ -244,7 +244,7 @@ void ApiListener::Start(bool runtimeCreated)
|
|||
|
||||
SyncLocalZoneDirs();
|
||||
|
||||
m_RenewOwnCertTimer = new Timer();
|
||||
m_RenewOwnCertTimer = Timer::Create();
|
||||
|
||||
if (Utility::PathExists(GetIcingaCADir() + "/ca.key")) {
|
||||
RenewOwnCert();
|
||||
|
@ -272,13 +272,13 @@ void ApiListener::Start(bool runtimeCreated)
|
|||
Application::Exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
m_Timer = new Timer();
|
||||
m_Timer = Timer::Create();
|
||||
m_Timer->OnTimerExpired.connect([this](const Timer * const&) { ApiTimerHandler(); });
|
||||
m_Timer->SetInterval(5);
|
||||
m_Timer->Start();
|
||||
m_Timer->Reschedule(0);
|
||||
|
||||
m_ReconnectTimer = new Timer();
|
||||
m_ReconnectTimer = Timer::Create();
|
||||
m_ReconnectTimer->OnTimerExpired.connect([this](const Timer * const&) { ApiReconnectTimerHandler(); });
|
||||
m_ReconnectTimer->SetInterval(10);
|
||||
m_ReconnectTimer->Start();
|
||||
|
@ -288,18 +288,18 @@ void ApiListener::Start(bool runtimeCreated)
|
|||
* Previous: 60s reconnect, 30s OA, 60s cold startup.
|
||||
* Now: 10s reconnect, 10s OA, 30s cold startup.
|
||||
*/
|
||||
m_AuthorityTimer = new Timer();
|
||||
m_AuthorityTimer = Timer::Create();
|
||||
m_AuthorityTimer->OnTimerExpired.connect([](const Timer * const&) { UpdateObjectAuthority(); });
|
||||
m_AuthorityTimer->SetInterval(10);
|
||||
m_AuthorityTimer->Start();
|
||||
|
||||
m_CleanupCertificateRequestsTimer = new Timer();
|
||||
m_CleanupCertificateRequestsTimer = Timer::Create();
|
||||
m_CleanupCertificateRequestsTimer->OnTimerExpired.connect([this](const Timer * const&) { CleanupCertificateRequestsTimerHandler(); });
|
||||
m_CleanupCertificateRequestsTimer->SetInterval(3600);
|
||||
m_CleanupCertificateRequestsTimer->Start();
|
||||
m_CleanupCertificateRequestsTimer->Reschedule(0);
|
||||
|
||||
m_ApiPackageIntegrityTimer = new Timer();
|
||||
m_ApiPackageIntegrityTimer = Timer::Create();
|
||||
m_ApiPackageIntegrityTimer->OnTimerExpired.connect([this](const Timer * const&) { CheckApiPackageIntegrity(); });
|
||||
m_ApiPackageIntegrityTimer->SetInterval(300);
|
||||
m_ApiPackageIntegrityTimer->Start();
|
||||
|
|
|
@ -47,7 +47,7 @@ static void EnsureFrameCleanupTimer()
|
|||
static boost::once_flag once = BOOST_ONCE_INIT;
|
||||
|
||||
boost::call_once(once, []() {
|
||||
l_FrameCleanupTimer = new Timer();
|
||||
l_FrameCleanupTimer = Timer::Create();
|
||||
l_FrameCleanupTimer->OnTimerExpired.connect([](const Timer * const&) { ScriptFrameCleanupHandler(); });
|
||||
l_FrameCleanupTimer->SetInterval(30);
|
||||
l_FrameCleanupTimer->Start();
|
||||
|
|
|
@ -11,13 +11,13 @@ BOOST_AUTO_TEST_SUITE(base_timer)
|
|||
|
||||
BOOST_AUTO_TEST_CASE(construct)
|
||||
{
|
||||
Timer::Ptr timer = new Timer();
|
||||
Timer::Ptr timer = Timer::Create();
|
||||
BOOST_CHECK(timer);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(interval)
|
||||
{
|
||||
Timer::Ptr timer = new Timer();
|
||||
Timer::Ptr timer = Timer::Create();
|
||||
timer->SetInterval(1.5);
|
||||
BOOST_CHECK(timer->GetInterval() == 1.5);
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ static void Callback(const Timer * const&)
|
|||
|
||||
BOOST_AUTO_TEST_CASE(invoke)
|
||||
{
|
||||
Timer::Ptr timer = new Timer();
|
||||
Timer::Ptr timer = Timer::Create();
|
||||
timer->OnTimerExpired.connect(&Callback);
|
||||
timer->SetInterval(1);
|
||||
|
||||
|
@ -45,7 +45,7 @@ BOOST_AUTO_TEST_CASE(invoke)
|
|||
|
||||
BOOST_AUTO_TEST_CASE(scope)
|
||||
{
|
||||
Timer::Ptr timer = new Timer();
|
||||
Timer::Ptr timer = Timer::Create();
|
||||
timer->OnTimerExpired.connect(&Callback);
|
||||
timer->SetInterval(1);
|
||||
|
||||
|
|
Loading…
Reference in New Issue