Lorah Attkins
Lorah Attkins

Reputation: 5856

Thread pool for std::async

In the documentation of std::async it's mentioned that (emphasis mine):

The function template async runs the function f asynchronously (potentially in a separate thread which might be a part of a thread pool) and returns a std::future that will eventually hold the result of that function call.

Is it possible to specify a thread pool for calls to async? If not can I somehow check whether a thread pool was used or not?

Upvotes: 0

Views: 1621

Answers (1)

Alex Guteniev
Alex Guteniev

Reputation: 13739

The standard std::async lack of this level of control, although implementation may provide such as non-standard guarantees/extensions.

The lack of this level of control is recognized -- there's https://wg21.link/p0443 proposal to address this.

For now the best option is probably to own thread pool using std::thread and std::packaged_task.

Upvotes: 1

Related Questions