Skip to content

Address #51: when_all/when_any result type #57

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 30, 2014
Merged

Address #51: when_all/when_any result type #57

merged 3 commits into from
Sep 30, 2014

Conversation

K-ballo
Copy link
Contributor

@K-ballo K-ballo commented Sep 29, 2014

First draft (not entirely happy with it):

  • Fixed return types.
  • Adjusted requirements (should accept any of future<R>, future<R>&, shared_future<R>, shared_future<R>&, shared_future<R> const, shared_future<R> const&),
  • Added when_any and when_any_back to synopsis.

Notes:

  • I fixed the inconsistent use of typename/class for these functions, but there are several other cases to take care of.
  • The wording makes use of both "first/second overload" and "first/second signature", it should be consistent (my vote goes to "overload").
  • I was surprised to see there's a variadic overload of when_any_back, since it cannot do anything differently than when_any. Was it introduced for symmetry? If so, I would suggest to be very explicit and spell out that the effects are equivalent to when_any.

@arturl
Copy link
Contributor

arturl commented Sep 29, 2014

Thanks, I'll take a look.
when_any_back(f1,f2) will produce a tuple in which the ready future will appear at position 1. What's the problem with this?

@K-ballo
Copy link
Contributor Author

K-ballo commented Sep 29, 2014

When when_any_swapped was introduced, it was only meant to deal with iterators. IIRC, the consensus was that a variadic overload was not worth the trouble since it can only work in limited scenarios, and the number of arguments to check is small anyways.

when_any_back(f1,f2) will produce a tuple in which the ready future will appear at position 1. What's the problem with this?

In order for that to be implementable, the decayed type of f1 and f2 has to be the exact same, so that we can put either of them at any position in the resulting tuple. It doesn't work for the general case, say if f1 is future<int> and f2 is future<void>. What's supposed to happen in that situation?

@arturl
Copy link
Contributor

arturl commented Sep 29, 2014

Right, the types of f1 and f2 must be the same for this to work. This weakens the argument for consistency with when_any.

@K-ballo
Copy link
Contributor Author

K-ballo commented Sep 29, 2014

My wording does not reflect this, and now I'm starting to fear that the intention of the current wording is to have some kind of movable initializer_list. I will have to think about this some more. We should at least be very clear about the intention, we can always defer precise wording to LWG.

arturl added a commit that referenced this pull request Sep 30, 2014
Address #51: when_all/when_any result type
@arturl arturl merged commit 732bcb3 into cplusplus:master Sep 30, 2014
@arturl
Copy link
Contributor

arturl commented Sep 30, 2014

@K-ballo: merged, thanks!

@K-ballo
Copy link
Contributor Author

K-ballo commented Sep 30, 2014

Ok, but keep in mind that this wording still doesn't cover the intent, at least for when_any_back. I'm still unsure as to what the intent is/was for when_all and when_any.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants