Is it possible to check if a std::future has finished or not? As far as I can tell the only way to do it would be to call wait_for with a zero duration and check if the status is ready or not, but is there a better way?
Is it possible to check if a std::future has finished or not? As far
Share
You are correct, and apart from calling
wait_untilwith 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:
N.B. if the function is deferred this will never return true, so it’s probably better to check
wait_fordirectly in the case where you might want to run the deferred task synchronously after a certain time has passed or when system load is low.