void sss(boost::promise<std::string>& res)
{
res.set_value("hi");
}
void yyy(boost::promise<std::string>& res)
{
res.set_value("hello");
}
int main()
{
boost::thread th;
boost::promise<std::string> a;
th = boost::thread(sss, boost::ref(a));
th.join();
std::cout << a.get_future().get() << std::endl;
th = boost::thread(yyy, boost::ref(a));
th.join();
std::cout << a.get_future().get() << std::endl;
}`
I'm getting the error that the promise is already satisfied. How to reuse the same object of promise?
Replace it with an unused promise:
a = boost::promise<std::string>();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With