C++ Language/Std/Multithreading/ReturnValue

From Wikibooks, open books for an open world
Jump to navigation Jump to search

To return a value from your worker thread, use a std::future<> return-value-getter object, whose get() function will block your client thread if the worker thread hasn't yet called set_value() on a corresponding std::promise<> return-value-setter object.

Additional information about returning a value from a thread (includes interactive examples)