-
Notifications
You must be signed in to change notification settings - Fork 7
thread_pool invoke
Alairion edited this page May 11, 2021
·
4 revisions
nes::thread_pool::invoke
template<typename Func, typename... Args>
(1) std::future<std::invoke_result_t<Func, Args...>> invoke(Func&& func, Args&&... args);
- Pushes a task in the thread pool. The return value of the function will be sent through the returned future. The future can also be used to know when the task is done. The function may returns
void
. The arguments to the function are moved or copied by value, if a reference argument needs to be passed, it has to be wrapped using std::[c]ref, or any other wrapper.
Name | Description |
---|---|
func |
The function to be executed. |
args |
The arguments to be passed to func. |
- Returns a future that will recieve the return value of
std::invoke(func, args...);
.
func
must be movable, and std::invoke(func, args...);
must be well-formed.
May throw a std::bad_alloc
or std::system_error
.