job/dispatch: retain the supplied function if forwarded to us

This commit is contained in:
Danny Robson 2018-03-27 16:20:56 +11:00
parent 45fa54a5ee
commit 62920f36f4

View File

@ -30,7 +30,9 @@ namespace util::job {
//
// threads will have work sizes dictated by a supplied extent.
//
// returns a cookie, or container of cookies, to wait on.
// returns a cookie that will block at destruction until all jobs have
// completed. it will take ownership of an forwarding-reference function
// if one is supplied.
//
// TODO: extend to 1d and 3d
template <
@ -39,12 +41,12 @@ namespace util::job {
typename ...Args,
size_t DimensionV
>
std::vector<queue::cookie>
auto
dispatch (
util::job::queue &q,
ContainerT &data,
util::extent<DimensionV,int> chunk,
FunctionT &func,
FunctionT &&func,
Args ...args)
{
auto chunked_func = [&func] (ContainerT &inner_data,
@ -74,7 +76,7 @@ namespace util::job {
);
}
return cookies;
return std::tuple (std::forward<FunctionT> (func), std::move (cookies));
}
}