}
// 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));
}
}
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
// 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
// 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
// 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
// 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
#define THREAD_POOL_H
#include <exceptions/exceptions.h>
+#include <boost/make_shared.hpp>
+#include <boost/shared_ptr.hpp>
#include <atomic>
#include <condition_variable>
///
/// @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) {
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));
}
}
}
/// @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_;