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

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -