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

Non-throwing channel::read and channel::write #76

Closed
anarthal opened this issue Aug 15, 2023 · 7 comments
Closed

Non-throwing channel::read and channel::write #76

anarthal opened this issue Aug 15, 2023 · 7 comments

Comments

@anarthal
Copy link

Would it be possible to have functions that don't throw, but return an error code, on cancellation?

@klemens-morgenstern
Copy link
Collaborator

There are a few solutions

  1. overload that's non-throwing
  2. make interrupt return a default constructed value if it's trivial
  3. make all of async system::result aware.

@anarthal
Copy link
Author

  1. sounds bad. 1. and 3. sound better. 3. is the one that sounds best.

@klemens-morgenstern
Copy link
Collaborator

What's bad about (2) ? The value gets ignored anyhow, so a channel<int> could just return 0.

@klemens-morgenstern
Copy link
Collaborator

interrupt_await could do (2) when used with select. Value gets ignored. If of course can't do that with regular read/write.

(1) would not work for non-default ctor-able T, so I think I should

add (2) for interrupt await & (3) for channel's only. I don't think stuff like promise<result<void, std::exception_ptr>> is necessary for now, but might be interesting.

@anarthal
Copy link
Author

  1. seems to not cover default-constructible types, either, unless I'm missing something.

I'd go for promise<result<T>> read(std::nothrow) or similar.

@klemens-morgenstern
Copy link
Collaborator

Is this really a general issue or rather one concerning using channels in a select statement?

@anarthal
Copy link
Author

In my case it was just with channels + select. I don't know enough about the library to say if this could happen under more situations.

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

2 participants