Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion score/mw/com/test/common_test_resources/proxy_container.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ class ProxyContainer
return *proxy_;
}

Proxy&& Extract()
/// \brief Extracts the proxy, leaving the ProxyContainer in a valid but unspecified state.
///
/// This function can only be called on an rvalue ProxyContainer, to make it clear that the ProxyContainer should
/// not be used after calling Extract()
Proxy&& Extract() &&
Comment thread
bemerybmw marked this conversation as resolved.
{
SCORE_LANGUAGE_FUTURECPP_ASSERT_PRD_MESSAGE(proxy_ != nullptr,
"Proxy was not successfully created! Cannot extract it!");
Expand Down
6 changes: 3 additions & 3 deletions score/mw/com/test/move_semantics/proxy_method/consumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void RunConsumerMoveConstruct(const std::string& failure_message_prefix)
std::cout << "\nConsumer: Step 1 - Find service and create proxy A" << std::endl;
ProxyContainer<ProxyMethodMoveSemanticsProxy> proxy_a_container{};
proxy_a_container.CreateProxy(kInstanceSpecifierMovedTo, failure_message_prefix);
auto proxy_a = proxy_a_container.Extract();
auto proxy_a = std::move(proxy_a_container).Extract();

// Step 2. Call method via proxy A (iteration 0: proxy works before the move)
std::cout << "\nConsumer: Step 2 - Call method via proxy A" << std::endl;
Expand All @@ -110,13 +110,13 @@ void RunConsumerMoveAssign(const std::string& failure_message_prefix)
std::cout << "\nConsumer: Step 1 - Find service and create proxy A" << std::endl;
ProxyContainer<ProxyMethodMoveSemanticsProxy> proxy_a_container{};
proxy_a_container.CreateProxy(kInstanceSpecifierMovedFrom, failure_message_prefix);
auto proxy_a = proxy_a_container.Extract();
auto proxy_a = std::move(proxy_a_container).Extract();

// Step 2. Find service and create proxy B (connected to the moved-to instance, which answers with a - b)
std::cout << "\nConsumer: Step 2 - Find service and create proxy B" << std::endl;
ProxyContainer<ProxyMethodMoveSemanticsProxy> proxy_b_container{};
proxy_b_container.CreateProxy(kInstanceSpecifierMovedTo, failure_message_prefix);
auto proxy_b = proxy_b_container.Extract();
auto proxy_b = std::move(proxy_b_container).Extract();

// Step 3. Call method via proxy A (iteration 0: proxy A works before the move, returns a + b)
std::cout << "\nConsumer: Step 3 - Call method via proxy A" << std::endl;
Expand Down
Loading