]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#883, !506] use boost:: instead of std::
authorRazvan Becheriu <razvan@isc.org>
Wed, 20 Nov 2019 11:26:42 +0000 (13:26 +0200)
committerRazvan Becheriu <razvan@isc.org>
Fri, 22 Nov 2019 07:19:23 +0000 (09:19 +0200)
src/lib/util/tests/thread_pool_unittest.cc
src/lib/util/thread_pool.h

index 7e209c097a9666ee7098a9357452e59e054eee43..2c90bb2e0c6f2f612a765961217a46e5d5b99839 100644 (file)
@@ -95,7 +95,7 @@ public:
         }
         // start test threads
         for (uint32_t i = 0; i < thread_count; ++i) {
-            threads_.push_back(make_shared<std::thread>(runFunction, this));
+            threads_.push_back(boost::make_shared<std::thread>(runFunction, this));
         }
     }
 
@@ -185,7 +185,7 @@ private:
     map<std::thread::id, list<uint32_t>> history_;
 
     /// @brief the list of test threads
-    list<shared_ptr<std::thread>> threads_;
+    list<boost::shared_ptr<std::thread>> threads_;
 };
 
 /// @brief define CallBack type
@@ -207,7 +207,7 @@ TEST_F(ThreadPoolTest, testAddAndCount) {
 
     // add items to stopped thread pool
     for (uint32_t i = 0; i < items_count; ++i) {
-        EXPECT_NO_THROW(thread_pool.add(make_shared<CallBack>(call_back)));
+        EXPECT_NO_THROW(thread_pool.add(boost::make_shared<CallBack>(call_back)));
     }
 
     // the item count should match
@@ -273,7 +273,7 @@ TEST_F(ThreadPoolTest, testStartAndStop) {
 
     // add items to stopped thread pool
     for (uint32_t i = 0; i < items_count; ++i) {
-        EXPECT_NO_THROW(thread_pool.add(make_shared<CallBack>(call_back)));
+        EXPECT_NO_THROW(thread_pool.add(boost::make_shared<CallBack>(call_back)));
     }
 
     // the item count should match
@@ -311,7 +311,7 @@ TEST_F(ThreadPoolTest, testStartAndStop) {
 
     // add items to running thread pool
     for (uint32_t i = 0; i < items_count; ++i) {
-        EXPECT_NO_THROW(thread_pool.add(make_shared<CallBack>(call_back)));
+        EXPECT_NO_THROW(thread_pool.add(boost::make_shared<CallBack>(call_back)));
     }
 
     // wait for all items to be processed
@@ -351,7 +351,7 @@ TEST_F(ThreadPoolTest, testStartAndStop) {
 
     // add items to stopped thread pool
     for (uint32_t i = 0; i < items_count; ++i) {
-        EXPECT_NO_THROW(thread_pool.add(make_shared<CallBack>(call_back)));
+        EXPECT_NO_THROW(thread_pool.add(boost::make_shared<CallBack>(call_back)));
     }
 
     // the item count should match
index 6016d6bb0c4aad97be3176b544937178cd8a9f48..5c89f95731f518037ab0da966267e278c1477dc6 100644 (file)
@@ -8,6 +8,8 @@
 #define THREAD_POOL_H
 
 #include <exceptions/exceptions.h>
+#include <boost/make_shared.hpp>
+#include <boost/shared_ptr.hpp>
 
 #include <atomic>
 #include <condition_variable>
@@ -24,9 +26,9 @@ namespace util {
 ///
 /// @tparam WorkItem a functor
 /// @tparam Container a 'queue like' container
-template <typename WorkItem, typename Container = std::queue<std::shared_ptr<WorkItem>>>
+template <typename WorkItem, typename Container = std::queue<boost::shared_ptr<WorkItem>>>
 struct ThreadPool {
-    typedef typename std::shared_ptr<WorkItem> WorkItemPtr;
+    typedef typename boost::shared_ptr<WorkItem> WorkItemPtr;
 
     /// @brief Constructor
     ThreadPool() : running_(false) {
@@ -103,7 +105,7 @@ private:
         queue_.enable();
         running_ = true;
         for (uint32_t i = 0; i < thread_count; ++i) {
-            threads_.push_back(std::make_shared<std::thread>(&ThreadPool::run, this));
+            threads_.push_back(boost::make_shared<std::thread>(&ThreadPool::run, this));
         }
     }
 
@@ -253,7 +255,7 @@ private:
     }
 
     /// @brief list of worker threads
-    std::vector<std::shared_ptr<std::thread>> threads_;
+    std::vector<boost::shared_ptr<std::thread>> threads_;
 
     /// @brief underlying work items queue
     ThreadPoolQueue<WorkItemPtr, Container> queue_;