-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closeable with suspendable aClose, and suspendable use extension. #240
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
Conversation
What kind of abstractions would implement this interface? |
The obvious use case is for IO.
Choice number 2 is better but then you only have fairly low level implementations. For a more concrete exemple, let's consider a rewrite of an sql database connection that |
We don't expect that any real-life implementations to use We are working an alternative asynchronous socket library (code-named "Coroutines IO" or CIO for short) that is directly based on the underlying NIO selectors (and directly on top of Posix in the future). This library extensively uses |
Alright, I understand that you might not want to use AsyncSocketChannel but something better instead. |
We already have an interface for this task. It is called a |
I don't think Job is the correct abstraction for this. I think it's too high level. It has a bunch of other methods that don't necessarily make sense for a simple closeable object. The example of the prepared statement is a good example of this. To me, job is more for tasks, and closeable is more for resource-like objects. At least that's what the name suggests, and the methods in the job interface also suggest this. |
I'm keeping it open, still looking for more use-case to decide on this abstraction. See we kind of have asynchronous close method on |
I think it's more a matter of semantics. In the case that I mentioned, I wouldn't want to have the database connection be a |
It's been a half a year since this PR and we still don't have a good use-case in a library, so I'm closing this PR. |
Closeable interface similar to java.io.Closeable, but with a suspendable aClose method.
I used the name aClose to be consistant with aRead and aWrite on channels.
I've added simple tests as well that check that the aClose method is called, whether an exception is thrown or not.