Skip to content
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

The interface of race (select) #103

Open
akrzemi1 opened this issue Sep 2, 2023 · 0 comments
Open

The interface of race (select) #103

akrzemi1 opened this issue Sep 2, 2023 · 0 comments

Comments

@akrzemi1
Copy link
Member

akrzemi1 commented Sep 2, 2023

The interface of select is not clearly documented, so it is difficult to figure out all the available signatures and return types. But judging from the rose in the documentation it is non-uniform.

The non-uniform interface of select() (spacial-case for all-void) is problematic and may cause unnecessary difficulties and surprises in generic contexts.

template <typename T, typename U> // is T a void?
promise<void> f(promise<T> pt, promise<U> pu)
{
  auto r = co_await select(pt, pu);
  r;  // which interface should I use?
      // variant or naked size_t?
}

Same goes for vector:

template <typename T> // is T a void?
promise<void> f(vector<<promise<T>> pv)
{
  auto r = co_await select(pv);
  r;  // which interface should I use?
      // pair or naked size_t?
}

Different interface calls for a different name. If promise<void> is orders of magnitude more frequent than promise<anything_else> then offer name selcetv for funcitons returning variant/pair. also, having two different functions would make it easier to document them.

Second issue. Because the documentation is too scarce, I cannot figure out what is returned by the select that is given a zero-sized vector of promises.

Third. Why do you use boost::variant2 rather than std::variant? I would expect a rationale in the docs.

@akrzemi1 akrzemi1 changed the title The interface of select The interface of race (select) Nov 9, 2023
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

No branches or pull requests

1 participant