Use invoke_result_t in threadpool
This commit is contained in:
parent
2ecbff1cdd
commit
272b5c1238
@ -1,6 +1,6 @@
|
||||
/**
|
||||
This file is a part of rexy's general purpose library
|
||||
Copyright (C) 2020 rexy712
|
||||
Copyright (C) 2020-2022 rexy712
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -29,6 +29,7 @@
|
||||
#include <future> //future, packaged_task
|
||||
#include <functional> //function, bind
|
||||
#include <utility> //move, forward
|
||||
#include <type_traits> //invoke_result_t
|
||||
|
||||
#include "rexy.hpp"
|
||||
|
||||
@ -62,14 +63,14 @@ namespace rexy{
|
||||
void invalidate(void);
|
||||
|
||||
template<class Func, class... Args>
|
||||
auto add_job(Func&& f, Args&&... args) -> std::future<decltype(std::forward<Func>(f)(std::forward<Args>(args)...))>;
|
||||
auto add_job(Func&& f, Args&&... args) -> std::future<std::invoke_result_t<Func,Args...>>;
|
||||
|
||||
private:
|
||||
void worker_loop(void);
|
||||
};
|
||||
|
||||
template<class Func, class... Args>
|
||||
auto threadpool::add_job(Func&& f, Args&&... args) -> std::future<decltype(std::forward<Func>(f)(std::forward<Args>(args)...))>{
|
||||
auto threadpool::add_job(Func&& f, Args&&... args) -> std::future<std::invoke_result_t<Func,Args...>>{
|
||||
using return_t = decltype(std::forward<Func>(f)(std::forward<Args>(args)...));
|
||||
using task_t = std::packaged_task<return_t(void)>;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user