made change of commit b997641ba4 template-based: no runtime cost
This commit is contained in:
parent
caafcfbaf9
commit
6e26ad2bf0
@ -52,8 +52,8 @@ class thread_pool
|
||||
/* the main loop of the threads */
|
||||
void loop();
|
||||
|
||||
template <typename F, typename... Args>
|
||||
auto _add_task_internal(bool front, F&& f, Args&&... args)
|
||||
template <bool front, typename F, typename... Args>
|
||||
auto _add_task_internal(F&& f, Args&&... args)
|
||||
-> std::future<decltype(f(std::forward<Args>(args)...))>;
|
||||
|
||||
public:
|
||||
@ -91,8 +91,8 @@ public:
|
||||
inline size_t get_queue_size() const { return queue.size(); }
|
||||
};
|
||||
|
||||
template <typename F, typename... Args>
|
||||
auto thread_pool::_add_task_internal(bool front, F&& f, Args&&... args)
|
||||
template <bool front, typename F, typename... Args>
|
||||
auto thread_pool::_add_task_internal(F&& f, Args&&... args)
|
||||
-> std::future<decltype(f(std::forward<Args>(args)...))>
|
||||
{
|
||||
auto pckgd_tsk = std::make_shared<std::packaged_task<decltype(f(std::forward<Args>(args)...))()> >
|
||||
@ -130,14 +130,14 @@ template <typename F, typename... Args>
|
||||
auto thread_pool::add_task(F&& f, Args&&... args)
|
||||
-> std::future<decltype(f(std::forward<Args>(args)...))>
|
||||
{
|
||||
return _add_task_internal(false, std::forward<F>(f), std::forward<Args>(args)...);
|
||||
return _add_task_internal<false>(std::forward<F>(f), std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <typename F, typename... Args>
|
||||
auto thread_pool::priority_task(F&& f, Args&&... args)
|
||||
-> std::future<decltype(f(std::forward<Args>(args)...))>
|
||||
{
|
||||
return _add_task_internal(true, std::forward<F>(f), std::forward<Args>(args)...);
|
||||
return _add_task_internal<true>(std::forward<F>(f), std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <typename R>
|
||||
|
Loading…
Reference in New Issue
Block a user