boostorg / boostorg/thread

when_all and when_any should probably not spawn a thread

Open
#112 5 comments 0 reactions 0 assignees View on GitHub
enhancement optimization
Dominant language
C++
Stars
214
Forks
171
PR merge metrics
No merged PRs in 30d

Description

The current implementation of boost::when_all and boost::when_any spawns a thread that calls wait_for_all or wait_for_any. This behaviour can result in explosive creation of OS threads when these functions are called often, which is probably not what the user expects since asynchronous primitives like futures are normally used as an alternatives to spawning lots of waiting threads.

As a simple workaround, future continuations can be used instead to asynchronously set the output future of when_all or when_any as appropriate when its input futures become ready. More efficient solutions probably exist to someone familiar with the Boost future implementation.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.