]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#886, !508] renamed class and moved sources
authorRazvan Becheriu <razvan@isc.org>
Mon, 4 Nov 2019 18:07:07 +0000 (20:07 +0200)
committerRazvan Becheriu <razvan@isc.org>
Mon, 4 Nov 2019 18:07:07 +0000 (20:07 +0200)
src/lib/dhcpsrv/Makefile.am
src/lib/dhcpsrv/tests/Makefile.am
src/lib/util/Makefile.am
src/lib/util/tests/Makefile.am
src/lib/util/tests/thread_resource_unittest.cc [moved from src/lib/dhcpsrv/tests/thread_resource_mgr_unittest.cc with 90% similarity]
src/lib/util/thread_resource.h [moved from src/lib/dhcpsrv/thread_resource_mgr.h with 98% similarity]

index 684e4655b37dca8e21ab82b0355b47e7812c2de3..948f01566aa3b0cf93cb3c28fc23fc29abd12e50 100644 (file)
@@ -117,7 +117,6 @@ libkea_dhcpsrv_la_SOURCES += lease_mgr.cc lease_mgr.h
 libkea_dhcpsrv_la_SOURCES += lease_mgr_factory.cc lease_mgr_factory.h
 libkea_dhcpsrv_la_SOURCES += memfile_lease_mgr.cc memfile_lease_mgr.h
 libkea_dhcpsrv_la_SOURCES += memfile_lease_storage.h
-libkea_dhcpsrv_la_SOURCES += thread_resource_mgr.h
 
 if HAVE_MYSQL
 libkea_dhcpsrv_la_SOURCES += mysql_lease_mgr.cc mysql_lease_mgr.h
index 8684f6379eaa0ee1743d69b0d7e72c8a5d385f44..d9cac94776fa096b9da89fee85c20e181f6ae346 100644 (file)
@@ -124,7 +124,6 @@ libdhcpsrv_unittests_SOURCES += shared_networks_list_parser_unittest.cc
 libdhcpsrv_unittests_SOURCES += srv_config_unittest.cc
 libdhcpsrv_unittests_SOURCES += subnet_unittest.cc
 libdhcpsrv_unittests_SOURCES += test_get_callout_handle.cc test_get_callout_handle.h
-libdhcpsrv_unittests_SOURCES += thread_resource_mgr_unittest.cc
 libdhcpsrv_unittests_SOURCES += triplet_unittest.cc
 libdhcpsrv_unittests_SOURCES += test_utils.cc test_utils.h
 libdhcpsrv_unittests_SOURCES += timer_mgr_unittest.cc
index cb643556d9d1d8cf4e88dbd7599e5976fc84cb9d..0f0e529a17e7972ed0dc1470e7fb8c53b6764812 100644 (file)
@@ -28,6 +28,7 @@ libkea_util_la_SOURCES += state_model.cc state_model.h
 libkea_util_la_SOURCES += stopwatch.cc stopwatch.h
 libkea_util_la_SOURCES += stopwatch_impl.cc stopwatch_impl.h
 libkea_util_la_SOURCES += strutil.h strutil.cc
+libkea_util_la_SOURCES += thread_resource.h
 libkea_util_la_SOURCES += time_utilities.h time_utilities.cc
 libkea_util_la_SOURCES += versioned_csv_file.h versioned_csv_file.cc
 libkea_util_la_SOURCES += watch_socket.cc watch_socket.h
index 68b3e31ea39fbd6e6079de685ab9db471f2831a9..ce86032a402fc8d71ad0875095cb4ede0734b062 100644 (file)
@@ -53,6 +53,7 @@ run_unittests_SOURCES += random_number_generator_unittest.cc
 run_unittests_SOURCES += staged_value_unittest.cc
 run_unittests_SOURCES += state_model_unittest.cc
 run_unittests_SOURCES += strutil_unittest.cc
+run_unittests_SOURCES += thread_resource_unittest.cc
 run_unittests_SOURCES += time_utilities_unittest.cc
 run_unittests_SOURCES += range_utilities_unittest.cc
 run_unittests_SOURCES += signal_set_unittest.cc
similarity index 90%
rename from src/lib/dhcpsrv/tests/thread_resource_mgr_unittest.cc
rename to src/lib/util/tests/thread_resource_unittest.cc
index eef73cf2c0a054b39955c1d16f075d59577ebb4c..09a35d8052045550210eb7cd48c292a75c22078f 100644 (file)
@@ -8,7 +8,7 @@
 
 #include <gtest/gtest.h>
 
-#include <dhcpsrv/thread_resource_mgr.h>
+#include <util/thread_resource.h>
 
 #include <boost/noncopyable.hpp>
 
@@ -121,15 +121,15 @@ std::mutex Resource<T>::mutex_;
 template <typename T>
 std::set<T*> Resource<T>::set_;
 
-/// @brief Test Fixture for testing isc::dhcp::ThreadResourceMgr
-class ThreadResourceMgrTest : public ::testing::Test {
+/// @brief Test Fixture for testing isc::dhcp::ThreadResource
+class ThreadResourceTest : public ::testing::Test {
 public:
     /// @brief Constructor
-    ThreadResourceMgrTest() : wait_thread_(false), wait_(false) {
+    ThreadResourceTest() : wait_thread_(false), wait_(false) {
     }
 
     /// @brief Destructor
-    ~ThreadResourceMgrTest() {
+    ~ThreadResourceTest() {
     }
 
     /// @brief flag which indicates if main thread should wait for the test
@@ -166,13 +166,13 @@ public:
         wait_cv_.notify_all();
     }
 
-    /// @brief reset resource manager for the specific class type and perform
-    /// sanity checks, then reset the wait flag so threads wait for the main
-    /// thread signal to exit
+    /// @brief reset resource for the specific class type and perform sanity
+    /// checks, then reset the wait flag so threads wait for the main thread
+    /// signal to exit
     template <typename T>
     void reset() {
-        // reset the resource manager
-        get<T>() = make_shared<ThreadResourceMgr<Resource<T>>>();
+        // reset the resource
+        get<T>() = make_shared<ThreadResource<Resource<T>>>();
         // perform sanity checks
         sanityCheck<T>();
         // reset the wait flag
@@ -201,13 +201,13 @@ public:
         ASSERT_EQ(Resource<T>::destroyedCount(), expected_destroyed);
     }
 
-    /// @brief get the instance of the resource manager responsible for a
-    /// specific class type
+    /// @brief get the instance of the resource responsible for a specific class
+    /// type
     ///
-    /// @return the resource manager responsible for a specific class type
+    /// @return the resource responsible for a specific class type
     template <typename T>
-    shared_ptr<ThreadResourceMgr<Resource<T>>> &get() {
-        static shared_ptr<ThreadResourceMgr<Resource<T>>> container;
+    shared_ptr<ThreadResource<Resource<T>>> &get() {
+        static shared_ptr<ThreadResource<Resource<T>>> container;
         return container;
     }
 
@@ -293,8 +293,8 @@ private:
 /// It is very important for the threads to run in parallel and not just run and
 /// join the thread as this will cause newer threads to use the old thread id
 /// and receive the same resource.
-/// If destroying threads, the resource manager should also be reset.
-TEST_F(ThreadResourceMgrTest, testThreadResources) {
+/// If destroying threads, the resource should also be reset.
+TEST_F(ThreadResourceTest, testThreadResources) {
     std::list<shared_ptr<std::thread>> threads;
 
     // reset statistics for uint_32 type
@@ -305,14 +305,14 @@ TEST_F(ThreadResourceMgrTest, testThreadResources) {
     resetWaitThread();
     // call run on a different thread and verify statistics
     threads.push_back(std::make_shared<std::thread>(std::bind(
-        &ThreadResourceMgrTest::run<uint32_t>, this, 2, 2, 0, true)));
+        &ThreadResourceTest::run<uint32_t>, this, 2, 2, 0, true)));
     // wait for the thread to process
     wait();
     // configure wait for test thread
     resetWaitThread();
     // call run again on a different thread and verify statistics
     threads.push_back(std::make_shared<std::thread>(std::bind(
-        &ThreadResourceMgrTest::run<uint32_t>, this, 3, 3, 0, true)));
+        &ThreadResourceTest::run<uint32_t>, this, 3, 3, 0, true)));
     // wait for the thread to process
     wait();
     // signal all threads
@@ -336,14 +336,14 @@ TEST_F(ThreadResourceMgrTest, testThreadResources) {
     resetWaitThread();
     // call run on a different thread and verify statistics
     threads.push_back(std::make_shared<std::thread>(std::bind(
-        &ThreadResourceMgrTest::run<bool>, this, 2, 2, 0, true)));
+        &ThreadResourceTest::run<bool>, this, 2, 2, 0, true)));
     // wait for the thread to process
     wait();
     // configure wait for test thread
     resetWaitThread();
     // call run again on a different thread and verify statistics
     threads.push_back(std::make_shared<std::thread>(std::bind(
-        &ThreadResourceMgrTest::run<bool>, this, 3, 3, 0, true)));
+        &ThreadResourceTest::run<bool>, this, 3, 3, 0, true)));
     // wait for the thread to process
     wait();
     // signal all threads
similarity index 98%
rename from src/lib/dhcpsrv/thread_resource_mgr.h
rename to src/lib/util/thread_resource.h
index 405e92f6114b7af41d0c502fdb5a2b8fa4caa7a4..bd360cbc7cb0c99b282ba8bcb2b89ae71d4f297b 100644 (file)
@@ -16,7 +16,7 @@ namespace isc {
 namespace dhcp {
 
 template <typename Resource>
-class ThreadResourceMgr {
+class ThreadResource {
     typedef std::shared_ptr<Resource> ResourcePtr;
 public:
     /// @brief function to retrieve the specific resource of calling thread