-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Split close(cause...)
into two interfaces
#325
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
Comments
We had an interface that extends both There does not see to be a need for another asynchronously closeable abstraction. It looks like |
@elizarov I'd like to advocate for this on more general utility/consistency terms.
There's also a consistency argument; |
@IonoclastBrigham I'm on the fence on this issue. On one side your argument is perfectly valid. Channels are closeable. On the other side, I don't want to promote the whole |
It looks something like... readerChannel(bufferedreader).use { chan ->
while (running) {
select<Unit> {
chan.onReceiveOrNull { line ->
// ...
}
// ...
}
}
} where |
@IonoclastBrigham We have However, it is not as convenient for your use-case as I cannot really explain it, but somehow I don't think we need any kind of "closeable" for channels, but we can define |
Closing this one as obsolete. |
Job
,ReceiveChannel
and possibly other interfaces have a common functionclose(cause: Throwable? = null)
. I see one issue and a couple of thoughts about this:Issue
Consider an interface which inherits from
Job
andReceiveChannel
:The compiler is upset because both interfaces have close w/default values.
Recommendations
Consider inheriting from
java.io.Closeable
(e.g. for auto close withuse
) and a new interface sayCloseableWithCause
. This will probably be a breaking change (close()
returnsBoolean
currently)The compiler is OK with the code below:
The text was updated successfully, but these errors were encountered: