You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@mesos.apache.org by "Benjamin Mahler (JIRA)" <ji...@apache.org> on 2015/08/01 02:55:04 UTC
[jira] [Created] (MESOS-3188) Add tuple-awareness to Future
callbacks.
Benjamin Mahler created MESOS-3188:
--------------------------------------
Summary: Add tuple-awareness to Future callbacks.
Key: MESOS-3188
URL: https://issues.apache.org/jira/browse/MESOS-3188
Project: Mesos
Issue Type: Improvement
Components: libprocess
Reporter: Benjamin Mahler
Future is currently single-valued and so the only way to create a multi-value Future is to use a custom struct or a tuple. Since Future is not currently "tuple-aware", continuations have to take a tuple as well, and manually unpack:
{code}
{
// Subprocess example.
await(s.get().status(),
io::read(s.get().out().get()),
io::read(s.get().err().get()))
.then(defer(self(), &Self::continue, lambda::_1));
}
void continue(std::tuple<
Future<Option<int>>,
Future<string>,
Future<string>> results)
{
Future<Option<int>> status = std::get<0>(results);
Future<string> output = std::get<1>(results);
Future<string> error = std::get<2>(results);
}
{code}
Since multi-value Future (i.e. Future<T1, T2, ...>) seems to be a bad design choice, being tuple aware can improve the code cleanliness by unpacking the tuple automatically for the continuation:
{code}
{
// Subprocess example.
await(s.get().status(),
io::read(s.get().out().get()),
io::read(s.get().err().get()))
.then(defer(self(), &Self::continue, lambda::_1));
}
void continue(
Future<Option<int>> status,
Future<string> output,
Future<string> error)
{
...
}
{code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)