[
https://issues.apache.org/jira/browse/MESOS-3188?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14652212#comment-14652212
]
Benjamin Mahler commented on MESOS-3188:
----------------------------------------
Sounds good!
> 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)