James Peach created MESOS-7907:
----------------------------------

             Summary: `async` fails to accept mutable lambdas
                 Key: MESOS-7907
                 URL: https://issues.apache.org/jira/browse/MESOS-7907
             Project: Mesos
          Issue Type: Bug
          Components: libprocess
            Reporter: James Peach


{{process::async}} fails to compile when you pass it a mutable lambda.

For example:
{code}
diff --git a/3rdparty/libprocess/src/tests/process_tests.cpp 
b/3rdparty/libprocess/src/tests/process_tests.cpp
index 8d3660070..399462fc2 100644
--- a/3rdparty/libprocess/src/tests/process_tests.cpp
+++ b/3rdparty/libprocess/src/tests/process_tests.cpp
@@ -1464,6 +1464,9 @@ TEST(ProcessTest, THREADSAFE_Async)

   // Non-void function that returns a future.
   EXPECT_EQ("42", async(&itoa1, &i).get().get());
+
+  int value = 99;
+  EXPECT_EQ(99, async([value] mutable { return value; }));
 }
{code}

Generates this compilation error:
{noformat}
In file included from 
../../../3rdparty/libprocess/src/tests/process_tests.cpp:32:0:
../../../3rdparty/libprocess/include/process/async.hpp: In instantiation of 
‘typename std::result_of<F()>::type 
process::AsyncExecutorProcess::execute(const F&) [with F = 
ProcessTest_THREADSAFE_Async_Test::TestBody()::<lambda()>; typename 
std::enable_if<(! std::is_void<typename std::result_of<F()>::type>::value), 
int>::type <anonymous> = 0; typename std::result_of<F()>::type = int]’:
../../../3rdparty/libprocess/include/process/async.hpp:184:74:   required from 
‘process::Future<typename std::result_of<F()>::type> 
process::AsyncExecutor::execute(const F&, typename std::enable_if<(! 
std::is_void<typename std::result_of<F()>::type>::value)>::type*) [with F = 
ProcessTest_THREADSAFE_Async_Test::TestBody()::<lambda()>; typename 
std::result_of<F()>::type = int; typename std::enable_if<(! 
std::is_void<typename std::result_of<F()>::type>::value)>::type = void]’
../../../3rdparty/libprocess/include/process/async.hpp:242:35:   required from 
‘process::Future<typename std::result_of<F()>::type> process::async(const F&, 
typename std::enable_if<(! std::is_void<typename 
std::result_of<F()>::type>::value)>::type*) [with F = 
ProcessTest_THREADSAFE_Async_Test::TestBody()::<lambda()>; typename 
std::result_of<F()>::type = int; typename std::enable_if<(! 
std::is_void<typename std::result_of<F()>::type>::value)>::type = void]’
../../../3rdparty/libprocess/src/tests/process_tests.cpp:1469:3:   required 
from here
../../../3rdparty/libprocess/include/process/async.hpp:87:13: error: no match 
for call to ‘(const ProcessTest_THREADSAFE_Async_Test::TestBody()::<lambda()>) 
()’
     return f();
            ~^~
{noformat}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to