Get the status of a std::future

You are correct, and apart from calling wait_until with a time in the past (which is equivalent) there is no better way. You could always write a little wrapper if you want a more convenient syntax: template<typename R> bool is_ready(std::future<R> const& f) { return f.wait_for(std::chrono::seconds(0)) == std::future_status::ready; } N.B. if the function is deferred this … Read more

Why should I use std::async?

it’s called async, but it got a really “sequential behaviour”, No, if you use the std::launch::async policy then it runs asynchronously in a new thread. If you don’t specify a policy it might run in a new thread. basically in the row where you call the future associated with your async function foo, the program … Read more

How to use invokeAll() to let all thread pool do their task?

The way an ExecutorService works is that when you call invokeAll it waits for all tasks to complete: Executes the given tasks, returning a list of Futures holding their status and results when all complete. Future.isDone() is true for each element of the returned list. Note that a completed task could have terminated either normally … Read more

How to configure a fine tuned thread pool for futures?

This answer is from monkjack, a comment from the accepted answer. However, one can miss this great answer so I’m reposting it here. implicit val ec = ExecutionContext.fromExecutor(Executors.newFixedThreadPool(10)) If you just need to change the thread pool count, just use the global executor and pass the following system properties. -Dscala.concurrent.context.numThreads=8 -Dscala.concurrent.context.maxThreads=8