I am worried about the hidden locking issues that may arise from these two parts of the code. For me, the first works, the second does not. I feel more confident that something like non-working code does not block, but it does not work correctly.
My question is: are these two parts of the code equivalent or the fact that I have .get() in the first continuation for working code can make my code locked at this point?
Working code.
auto finished = user2.ReceiveChatMessages().then([&] (boost::future<std::vector<ServerReply>> && receivedMessages) { number_received_messages_in_continuation = receivedMessages.get().size(); //Will this .get make my code block in any case? return user2.ReceiveChatMessages().get(); }) .then([&](boost::future<std::vector<ServerReply>> && receivedMessages) { number_received_messages_in_continuation += receivedMessages.get().size(); });
Inoperative code.
auto finished = user2.ReceiveChatMessages().then([&] (boost::future<std::vector<ServerReply>> && receivedMessages) { number_received_messages_in_continuation = receivedMessages.get().size(); //No .get() here return user2.ReceiveChatMessages(); }).unwrap() //We need to unwrap .then([&](boost::future<std::vector<ServerReply>> && receivedMessages) { number_received_messages_in_continuation += receivedMessages.get().size(); });
source share