From: Marcin Siodelski Date: Wed, 2 Sep 2015 12:08:47 +0000 (+0200) Subject: [3970] Rename 'deregister' to 'unregister' in TimerMgr. X-Git-Tag: fd4o6_base~5^2~5 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=114f9004ddcf79ed12e313b8317da73800acee34;p=thirdparty%2Fkea.git [3970] Rename 'deregister' to 'unregister' in TimerMgr. --- diff --git a/src/lib/dhcpsrv/tests/timer_mgr_unittest.cc b/src/lib/dhcpsrv/tests/timer_mgr_unittest.cc index 0664ad96a6..66cfd154cd 100644 --- a/src/lib/dhcpsrv/tests/timer_mgr_unittest.cc +++ b/src/lib/dhcpsrv/tests/timer_mgr_unittest.cc @@ -109,7 +109,7 @@ TimerMgrTest::TearDown() { // Make sure there are no dangling threads. TimerMgr::instance().stopThread(); // Remove all timers. - TimerMgr::instance().deregisterTimers(); + TimerMgr::instance().unregisterTimers(); } void @@ -207,9 +207,9 @@ TEST_F(TimerMgrTest, registerTimer) { } -// 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. @@ -227,12 +227,12 @@ TEST_F(TimerMgrTest, deregisterTimer) { 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()); @@ -240,17 +240,17 @@ TEST_F(TimerMgrTest, deregisterTimer) { 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. @@ -283,8 +283,8 @@ TEST_F(TimerMgrTest, DISABLED_deregisterTimers) { // 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()); @@ -296,19 +296,19 @@ TEST_F(TimerMgrTest, DISABLED_deregisterTimers) { 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. @@ -402,13 +402,13 @@ TEST_F(TimerMgrTest, scheduleTimers) { 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); diff --git a/src/lib/dhcpsrv/timer_mgr.cc b/src/lib/dhcpsrv/timer_mgr.cc index 1361b7cc3b..956efed7a2 100644 --- a/src/lib/dhcpsrv/timer_mgr.cc +++ b/src/lib/dhcpsrv/timer_mgr.cc @@ -40,9 +40,9 @@ TimerMgr::TimerMgr() } 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(); } @@ -96,7 +96,7 @@ TimerMgr::registerTimer(const std::string& timer_name, } 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) @@ -129,7 +129,7 @@ TimerMgr::deregisterTimer(const std::string& timer_name) { } void -TimerMgr::deregisterTimers() { +TimerMgr::unregisterTimers() { LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE, DHCPSRV_TIMERMGR_UNREGISTER_ALL_TIMERS); @@ -137,7 +137,7 @@ TimerMgr::deregisterTimers() { // 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 @@ -145,10 +145,10 @@ TimerMgr::deregisterTimers() { // 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); } } diff --git a/src/lib/dhcpsrv/timer_mgr.h b/src/lib/dhcpsrv/timer_mgr.h index 4aa14ea1c0..e6c4a1b57f 100644 --- a/src/lib/dhcpsrv/timer_mgr.h +++ b/src/lib/dhcpsrv/timer_mgr.h @@ -86,20 +86,20 @@ namespace dhcp { /// 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 @@ -109,7 +109,7 @@ public: /// @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. @@ -129,22 +129,22 @@ public: 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. /// @@ -204,7 +204,7 @@ private: /// @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();