[SERVER-19237] NetworkInterface::RemoteCommandCompletionFn should take ResponseStatus by r-value reference Created: 01/Jul/15  Updated: 18/Aug/15  Resolved: 14/Aug/15

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Adam Midvidy Assignee: Samantha Ritter (Inactive)
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Platform 8 08/28/15
Participants:

 Description   

The completion function should take ownership of the struct as it is not used after the completion handler is called by the NetworkInterface.



 Comments   
Comment by Samantha Ritter (Inactive) [ 14/Aug/15 ]

To fix this ticket we'd want to have calls of the following form to NetworkInterface::startCommand():

startCommand(someValue,
             someRequest,
             [capture things](ResponseStatus&& response) {
     // do some stuff with the response from the remote server
}

So, we'd like the completion handler to take a ResponseStatus by && as shown above. However, the task executor uses a callback with the following format:

[capture some things](ResponseStatus&& response) {
     ...
     auto anotherCallback = [response](...) {
          remoteCommandFinished(..., std::move(response));
     }
     ...
}

We want to pass 'response' by && all the way down through various callbacks, so we try to std::move() it along. However, this will not compile because we haven't captured 'response' by &&, we've captured it by const &:

auto anotherCallback = [response](...) {

If we could type the following then we'd be able to make this change:

auto anotherCallback = [std::move(response)](...) {

Sadly, we won't have move lambda captures until C++14, so I am closing this ticket as "Won't Fix."

Generated at Thu Feb 08 03:50:17 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.