Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
thelfer committed Sep 5, 2024
1 parent 5cb6e39 commit bb53041
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion include/MGIS/ThreadPool.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace mgis {
* \param[in] a: arguments passed to the the task
*/
template <typename F, typename... Args>
std::future<ThreadedTaskResult<typename std::invoke_result<F(Args...)>::type>>
std::future<ThreadedTaskResult<std::invoke_result_t<F, Args...>>>
addTask(F&&, Args&&...);
//! \return the number of threads managed by the ppol
size_type getNumberOfThreads() const;
Expand Down
13 changes: 6 additions & 7 deletions include/MGIS/ThreadPool.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ namespace mgis {
struct ThreadPool::Wrapper {
Wrapper(F&& f_) : f(f_) {}
template <typename... Args>
ThreadedTaskResult<typename std::invoke_result<F(Args...)>::type> operator()(
ThreadedTaskResult<std::invoke_result_t<F, Args...>> operator()(
Args&&... args) {
using result = typename std::invoke_result<F(Args...)>::type;
using apply = typename std::conditional<std::is_same<result, void>::value,
GetVoid, Get<result>>::type;
using result = std::invoke_result_t<F, Args...>;
using apply = std::conditional_t<std::is_same_v<result, void>, GetVoid,
Get<result>>;
ThreadedTaskResult<result> r;
apply::exe(r, f, std::forward<Args>(args)...);
return r;
Expand Down Expand Up @@ -61,10 +61,9 @@ namespace mgis {

// add new work item to the pool
template <typename F, typename... Args>
std::future<ThreadedTaskResult<typename std::invoke_result<F(Args...)>::type>>
std::future<ThreadedTaskResult<std::invoke_result_t<F, Args...>>>
ThreadPool::addTask(F&& f, Args&&... a) {
using return_type =
ThreadedTaskResult<typename std::invoke_result<F(Args...)>::type>;
using return_type = ThreadedTaskResult<std::invoke_result_t<F, Args...>>;
using task = std::packaged_task<return_type()>;
auto t = std::make_shared<task>(
std::bind(Wrapper<F>(std::forward<F>(f)), std::forward<Args>(a)...));
Expand Down

0 comments on commit bb53041

Please sign in to comment.