You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I’d like to use this overload of CancellableContinuation.resume() in OkHttp’s coroutines extension.
@ExperimentalCoroutinesApi // since 1.2.0
public fun resume(value: T, onCancellation: ((cause: Throwable) -> Unit)?)
Unfortunately, this functino is experimental. There’s no stable alternative that combines continuations with safe resource management. I’m going to annotate our own API with @ExperimentalCoroutinesApi to pass the responsibility to our callers.
I’d like for you to consider removing the experimental annotation from this function. It hasn’t changed since 2020. It solves an important very nicely!
The text was updated successfully, but these errors were encountered:
We've been sitting on that for a while for quite a specific reason: its signature should've been (value: T, cause: Throwable) -> Unit, otherwise, when serving its main purpose, it is a capturing lambda that always allocates, even though there are no reasons real reasons to.
Changing that, there is a variance conflict -- continuations are contravariant (in T) and functional types are covariant (out T), which forces us to fallback to @UnsafeVariance and ensure that it's sound.
There was an extended attempt (#3093) to change that and also receive a CoroutineContext as the third parameter, though this part remains questionable, and we never figured it out.
Taking into account it's experimental for so long if we are going to change the signature and deprecate it, this version is going to stay basically forever.
If you have any opinions on the current or potential API shape -- don't hesitate to tell us!
I’d like to use this overload of
CancellableContinuation.resume()
in OkHttp’s coroutines extension.Unfortunately, this functino is experimental. There’s no stable alternative that combines continuations with safe resource management. I’m going to annotate our own API with
@ExperimentalCoroutinesApi
to pass the responsibility to our callers.I’d like for you to consider removing the experimental annotation from this function. It hasn’t changed since 2020. It solves an important very nicely!
The text was updated successfully, but these errors were encountered: