summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp15
1 files changed, 4 insertions, 11 deletions
diff --git a/src/main.cpp b/src/main.cpp
index b5abad9..2e2f1b2 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -18,13 +18,6 @@ static volatile std::atomic<bool> reload(false);
// flag is set and all connections are closed, we can exit properly.
static bool exiting = false;
-// The global (and only) TimedEventsManager. It can be accessed by any
-// class to add new TimedEvents, and it is used in the main loop to provide
-// a timeout to the poller, this way the method execute_expired_events can
-// be called on time, without having to do an active “poll” on it every n
-// seconds.
-TimedEventsManager timed_events;
-
/**
* Provide an helpful message to help the user write a minimal working
* configuration file.
@@ -43,7 +36,7 @@ int config_help(const std::string& missing_option)
static void sigint_handler(int sig, siginfo_t*, void*)
{
// In 2 seconds, repeat the same signal, to force the exit
- timed_events.add_event(TimedEvent(std::chrono::steady_clock::now() + 2s,
+ TimedEventsManager::instance().add_event(TimedEvent(std::chrono::steady_clock::now() + 2s,
[sig]() { raise(sig); }));
stop.store(true);
}
@@ -101,10 +94,10 @@ int main(int ac, char** av)
xmpp_component->start();
- auto timeout = timed_events.get_timeout();
+ auto timeout = TimedEventsManager::instance().get_timeout();
while (p->poll(timeout) != -1)
{
- timed_events.execute_expired_events();
+ TimedEventsManager::instance().execute_expired_events();
// Check for empty irc_clients (not connected, or with no joined
// channel) and remove them
xmpp_component->clean();
@@ -143,7 +136,7 @@ int main(int ac, char** av)
xmpp_component->close();
if (exiting && p->size() == 1 && xmpp_component->is_document_open())
xmpp_component->close_document();
- timeout = timed_events.get_timeout();
+ timeout = TimedEventsManager::instance().get_timeout();
}
log_info("All connection cleanely closed, have a nice day.");
return 0;