// Make sure there are no dangling threads.
TimerMgr::instance().stopThread();
// Remove all timers.
- TimerMgr::instance().deregisterTimers();
+ TimerMgr::instance().unregisterTimers();
}
void
}
-// This test verifies that it is possible to deregister a timer from
+// This test verifies that it is possible to unregister a timer from
// the TimerMgr.
-TEST_F(TimerMgrTest, deregisterTimer) {
+TEST_F(TimerMgrTest, unregisterTimer) {
TimerMgr& timer_mgr = TimerMgr::instance();
// Register a timer and start it.
const unsigned int calls_count = calls_count_["timer1"];
ASSERT_GT(calls_count, 0);
- // Check that an attempt to deregister a non-existing timer would
+ // Check that an attempt to unregister a non-existing timer would
// result in exeception.
- EXPECT_THROW(timer_mgr.deregisterTimer("timer2"), BadValue);
+ EXPECT_THROW(timer_mgr.unregisterTimer("timer2"), BadValue);
- // Now deregister the correct one.
- ASSERT_NO_THROW(timer_mgr.deregisterTimer("timer1"));
+ // Now unregister the correct one.
+ ASSERT_NO_THROW(timer_mgr.unregisterTimer("timer1"));
// Start the thread again and wait another 100ms.
ASSERT_NO_THROW(timer_mgr.startThread());
ASSERT_NO_THROW(timer_mgr.stopThread());
// The number of calls for the timer1 shouldn't change as the
- // timer had been deregistered.
+ // timer had been unregistered.
EXPECT_EQ(calls_count_["timer1"], calls_count);
}
-// This test verifies taht it is possible to deregister all timers.
+// This test verifies taht it is possible to unregister all timers.
/// @todo This test is disabled because it may occassionally hang
/// due to bug in the ASIO implementation shipped with Kea.
/// Replacing it with the ASIO implementation from BOOST does
/// solve the problem. See ticket #4009. Until this ticket is
/// implemented, the test should remain disabled.
-TEST_F(TimerMgrTest, DISABLED_deregisterTimers) {
+TEST_F(TimerMgrTest, DISABLED_unregisterTimers) {
TimerMgr& timer_mgr = TimerMgr::instance();
// Register 10 timers.
// Copy counters for all timers.
CallsCount calls_count(calls_count_);
- // Let's deregister all timers.
- ASSERT_NO_THROW(timer_mgr.deregisterTimers());
+ // Let's unregister all timers.
+ ASSERT_NO_THROW(timer_mgr.unregisterTimers());
// Start worker thread again and wait for 500ms.
ASSERT_NO_THROW(timer_mgr.startThread());
EXPECT_TRUE(calls_count == calls_count_);
}
-// This test checks that it is not possible to deregister timers
+// This test checks that it is not possible to unregister timers
// while the thread is running.
-TEST_F(TimerMgrTest, deregisterTimerWhileRunning) {
+TEST_F(TimerMgrTest, unregisterTimerWhileRunning) {
TimerMgr& timer_mgr = TimerMgr::instance();
// Register two timers.
ASSERT_NO_FATAL_FAILURE(registerTimer("timer1", 1));
ASSERT_NO_FATAL_FAILURE(registerTimer("timer2", 1));
- // Start the thread and make sure we can't deregister them.
+ // Start the thread and make sure we can't unregister them.
ASSERT_NO_THROW(timer_mgr.startThread());
- EXPECT_THROW(timer_mgr.deregisterTimer("timer1"), InvalidOperation);
- EXPECT_THROW(timer_mgr.deregisterTimers(), InvalidOperation);
+ EXPECT_THROW(timer_mgr.unregisterTimer("timer1"), InvalidOperation);
+ EXPECT_THROW(timer_mgr.unregisterTimers(), InvalidOperation);
// No need to stop the thread as it will be stopped by the
// test fixture destructor.
unsigned int calls_count_timer1 = calls_count_["timer1"];
unsigned int calls_count_timer2 = calls_count_["timer2"];
- // Deregister the 'timer1'.
- ASSERT_NO_THROW(timer_mgr.deregisterTimer("timer1"));
+ // Unregister the 'timer1'.
+ ASSERT_NO_THROW(timer_mgr.unregisterTimer("timer1"));
// Restart the thread.
ASSERT_NO_THROW(timer_mgr.startThread());
- // Wait another 500ms. The 'timer1' was deregistered so it
+ // Wait another 500ms. The 'timer1' was unregistered so it
// should not make any more calls. The 'timer2' should still
// work as previously.
doWait(500);
}
TimerMgr::~TimerMgr() {
- // Stop the thread, but do not deregister any timers. Deregistering
+ // Stop the thread, but do not unregister any timers. Unregistering
// the timers could cause static deinitialization fiasco between the
- // TimerMgr and IfaceMgr. By now, the caller should have deregistered
+ // TimerMgr and IfaceMgr. By now, the caller should have unregistered
// the timers.
stopThread();
}
}
void
-TimerMgr::deregisterTimer(const std::string& timer_name) {
+TimerMgr::unregisterTimer(const std::string& timer_name) {
LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE,
DHCPSRV_TIMERMGR_UNREGISTER_TIMER)
}
void
-TimerMgr::deregisterTimers() {
+TimerMgr::unregisterTimers() {
LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE,
DHCPSRV_TIMERMGR_UNREGISTER_ALL_TIMERS);
// Copy the map holding timers configuration. This is required so as
// we don't cut the branch which we're sitting on when we will be
// erasing the timers. We're going to iterate over the register timers
- // and remove them with the call to deregisterTimer function. But this
+ // and remove them with the call to unregisterTimer function. But this
// function will remove them from the register_timers_ map. If we
// didn't work on the copy here, our iterator would invalidate. The
// TimerInfo structure is copyable and since it is using the shared
// the process terminates so it is not critical for performance.
TimerInfoMap registered_timers_copy(registered_timers_);
- // Iterate over the existing timers and deregister them.
+ // Iterate over the existing timers and unregister them.
for (TimerInfoMap::iterator timer_info_it = registered_timers_copy.begin();
timer_info_it != registered_timers_copy.end(); ++timer_info_it) {
- deregisterTimer(timer_info_it->first);
+ unregisterTimer(timer_info_it->first);
}
}
/// race conditions between the worker thread and the main thread
/// if the latter is modifying the collection of the registered
/// timers. Therefore, the @c TimerMgr does not allow for
-/// registering or deregistering the timers when the worker thread
+/// registering or unregistering the timers when the worker thread
/// is running. The worker thread must be stopped first.
///
/// @warning The application (DHCP server) is responsible for
-/// deregistering the timers before it terminates:
+/// unregistering the timers before it terminates:
/// @code
-/// TimerMgr::instance().deregisterTimers();
+/// TimerMgr::instance().unregisterTimers();
/// @endcode
///
/// to avoid the static deinitialization fiasco between the @c TimerMgr
/// and @c IfaceMgr. Note that the @c TimerMgr destructor doesn't
-/// deregister the timers to avoid referencing the @c IfaceMgr
+/// unregister the timers to avoid referencing the @c IfaceMgr
/// instance which may not exist at this point. If the timers are
-/// not deregistered before the application terminates this will
+/// not unregistered before the application terminates this will
/// likely result in segmentation fault on some systems.
///
/// All timers are associated with the callback function
/// @brief Returns sole instance of the @c TimerMgr singleton.
static TimerMgr& instance();
- /// @name Registering, deregistering and scheduling the timers.
+ /// @name Registering, unregistering and scheduling the timers.
//@{
/// @brief Registers new timers in the @c TimerMgr.
const long interval,
const asiolink::IntervalTimer::Mode& scheduling_mode);
- /// @brief Deregisters specified timer.
+ /// @brief Unregisters specified timer.
///
/// This method cancels the timer if it is setup. It removes the external
/// socket from the @c IfaceMgr and closes it. It finally removes the
/// timer from the internal collection of timers.
///
- /// @param timer_name Name of the timer to be deregistered.
+ /// @param timer_name Name of the timer to be unregistered.
///
/// @throw BadValue if the specified timer hasn't been registered.
- void deregisterTimer(const std::string& timer_name);
+ void unregisterTimer(const std::string& timer_name);
- /// @brief Deregisters all timers.
+ /// @brief Unregisters all timers.
///
/// This method must be explicitly called prior to termination of the
/// process.
- void deregisterTimers();
+ void unregisterTimers();
/// @brief Schedules the execution of the interval timer.
///
/// @brief Private destructor.
///
- /// Stops the worker thread if it is running. It doesn't deregister any
+ /// Stops the worker thread if it is running. It doesn't unregister any
/// timers to avoid static deinitialization fiasco with the @c IfaceMgr.
~TimerMgr();