[MS] C++ futures part 5: std::future and std::shared_future - devamazonaws.blogspot.com
Wrapping up our quick introduction to the C++ futures library , we come to the last two parts: std:: future and std:: shared_future . The std:: future is the starting point. It is a move-only class that this takes the source and forwards its wait and wait_for methods to the source , and forwards its get method to consume . Forwarding the get to consume means that you can call get only once. The idea is that std:: future is for the case where there is exactly one consumer of the value. Since it is move-only, you can't copy it; you can only give it away and transfer the power to retrieve the value to the recipient. The std:: future has a method called shared() . This transfers the source from the future to a shared_ future object. The shared_ future also forwards its wait and wait_for methods to the source , but instead of forwarding its get to the source:: consume , shared_ future:: get() just calls source:: get to get a reference to the value storage. This...