std future and std promise
suggest changeThe following example sets a promise to be consumed by another thread:
{
auto promise = std::promise<std::string>();
auto producer = std::thread([&]
{
promise.set_value("Hello World");
});
auto future = promise.get_future();
auto consumer = std::thread([&]
{
std::cout << future.get();
});
producer.join();
consumer.join();
}
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents