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

avoid fatalError #15

Open
xlc opened this issue Oct 17, 2024 · 3 comments
Open

avoid fatalError #15

xlc opened this issue Oct 17, 2024 · 3 comments

Comments

@xlc
Copy link
Contributor

xlc commented Oct 17, 2024

It will be good if the API can be improved to avoid fatalError. e.g. throw or return false on trying to send on a closed channel.

@gh123man
Copy link
Owner

Perhaps we can introduce a sendOrThrow function that throws when the channel is closed? Such a function could optionally be used in place of send. Would this work for you?

This library is heavily modeled after go and one of those design choices is not allowing a send on closed channel. However we can support both by making a more explicit function for this behavior.

@xlc
Copy link
Contributor Author

xlc commented Oct 18, 2024

that will work. maybe we can call it trySend but that could have other means (e.g. only send when buffer is not full)

@gh123man
Copy link
Owner

I had considered trySend however I feel that it would read weird when written like:

do { 
    try trySend()
} catch ...

Ill put some more thought into it.

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