Skip to content

thread_pool invoke

Alairion edited this page May 11, 2021 · 4 revisions

Functions

    template<typename Func, typename... Args>
(1) std::future<std::invoke_result_t<Func, Args...>> invoke(Func&& func, Args&&... args);
  1. 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.

Parameters

Name Description
func The function to be executed.
args The arguments to be passed to func.

Return value

  1. Returns a future that will recieve the return value of std::invoke(func, args...);.

Preconditions

func must be movable, and std::invoke(func, args...); must be well-formed.

Exceptions

May throw a std::bad_alloc or std::system_error.

Clone this wiki locally