[REQ] [[nodiscard]] on submit debateable.
mokafolio opened this issue · 3 comments
I think there are valid use cases in which you don't want to use the std::future
returned from submit
. One such example is if your task manages it's own future. One example of using your own future could be that you want to support both async and blocking loading and hence need to have a little bit more control over promise/future/shared_future interactions. While I don't think it's a big deal, the [[nodiscard]]
is not appropriate in my opinion.
On the contrary, the [[nodiscard]]
is crucial here. Calling submit()
and discarding the future it returns is a huge waste of time and resources, because submit()
goes to considerable effort to create the promise and populate the future (not to mention allocating a shared pointer). If you don't need the future, simply use push_task()
instead.
You are absolutely right, when scanning the source I wrongly perceived push_task
as an internal function. Thanks for the heads up!
No worries! :)