c++ - Get the status of a std::future -
is possible check if std::future has finished or not? far can tell way call wait_for 0 duration , check if status ready or not, there better way?
you correct, , apart calling wait_until time in past (which equivalent) there no better way.
you write little wrapper if want 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 function deferred never return true, it's better check wait_for directly in case might want run deferred task synchronously after time has passed or when system load low.
Comments
Post a Comment