The std::shared_future is a C++11 synchronization tool suitable for one-shot single-producer/many-consumers situations. Unlike std::future, std::shared_future is copyable, allowing multiple instances of std::shared_future to refer to the same shared state. Similar to std::future, std::shared_future<void> can be used for signalling. Compiler Explorer link: https://lnkd.in/eGRbm94q #cpp #cplusplus #coding #programming #dailybiteofcpp
Does we have some mechanisms like promise/future but not getting invalid future after one set_value for the promise? Something like set the promise calue multiple time and also get the future multiple times? (I think we can get that using condition variable and notify function, but is it possible via promise/future?)
HiArc•4K followers
2yWhat’s the difference between a shared_future<T> and a shared_ptr<future<T>> ? Based on your example it seems like it’s a type alias. If you pass promise.get_future() into the shared_ptr ctor, it should work the same?