I have a thread waiting on a future. In the event where my application is shut down, I would like to join the thread. How do I go about notifying the future without fudging it and setting it to some value?
auto promise = std::promise<std::string>();
...
auto future = promise.get_future();
auto consumer = std::thread([&]
{
while (future.wait_for(10ms)){
// do something
std::cout << future.get().c_str();
}
});
...
consumer.join();
Aucun commentaire:
Enregistrer un commentaire