job/dispatch: retain the supplied function if forwarded to us
This commit is contained in:
parent
45fa54a5ee
commit
62920f36f4
@ -30,7 +30,9 @@ namespace util::job {
|
|||||||
//
|
//
|
||||||
// threads will have work sizes dictated by a supplied extent.
|
// 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
|
// TODO: extend to 1d and 3d
|
||||||
template <
|
template <
|
||||||
@ -39,12 +41,12 @@ namespace util::job {
|
|||||||
typename ...Args,
|
typename ...Args,
|
||||||
size_t DimensionV
|
size_t DimensionV
|
||||||
>
|
>
|
||||||
std::vector<queue::cookie>
|
auto
|
||||||
dispatch (
|
dispatch (
|
||||||
util::job::queue &q,
|
util::job::queue &q,
|
||||||
ContainerT &data,
|
ContainerT &data,
|
||||||
util::extent<DimensionV,int> chunk,
|
util::extent<DimensionV,int> chunk,
|
||||||
FunctionT &func,
|
FunctionT &&func,
|
||||||
Args ...args)
|
Args ...args)
|
||||||
{
|
{
|
||||||
auto chunked_func = [&func] (ContainerT &inner_data,
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user