Asynchronous or stream pool

Is there any particular reason why one should prefer std :: async or std :: thread over thread pool?

Basically, async is a std :: thread with a result and a startup policy, which means that async performance will depend on the pool, since creating threads is really expensive.

Now I am curious if there is a reason why I should use async instead of pooling if I run tasks very often? For long running tasks I definitely see an advantage, but for small tasks I don't see any benefit at all from asynchronous.

Even for large tasks, I would rather use a larger thread pool and agree that 1 or 2 threads are busy for a fixed amount of time, as I like to have all my threads at one point.

I don't understand why there is no implementation of std :: thread_pool at all, as I see quite a few reasons why I should start threads (with async ot std :: thread) at runtime, if I can avoid it altogether due to the cost of spawning of new streams. Can anyone give me a valid reason why I should use asyncs or why there is no thread pool in the standard?

+3


source to share





All Articles