-
Notifications
You must be signed in to change notification settings - Fork 65
[core] move fromCompletionStage from Fiber to Async #1195
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
@@ -3,17 +3,14 @@ package kyo.internal | |||
import java.util.concurrent.CompletionStage | |||
import kyo.* | |||
|
|||
trait FiberPlatformSpecific: | |||
trait AsyncPlatformSpecific: | |||
def fromCompletionStage[A](cs: CompletionStage[A])(using Frame): A < Async = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can alias this to fromFuture
as well. It should typecheck as an overload (to Scala's future).
@@ -1028,7 +1028,7 @@ class ChannelTest extends Test: | |||
latch.await.andThen(channel.close) | |||
) | |||
_ <- latch.release | |||
_ <- channel.drain | |||
_ <- Abort.run(channel.drain) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@steinybot This might fix the test flakiness. it seems expected that the channel can be closed at this point since it's a race with closeFiber
### Problem Following the rationale of #1195, `Channel` and `Hub` should avoid exposing `Fiber` in its APIs. ### Solution Remove the `takeFiber` and `putFiber` methods from both `Channel` and `Hub`. There's a performance cost in case a `Fiber` instance is needed but I think usability should be a priority.
Problem
Fiber
is a low-level effect with complex semantics for newcomers. Its functionality is essential for integrations and more low-level code butAsync
provides better usability and covers a majority of use cases. For this reason,Fiber
's API has become more limited over time and we don't even provide common combinators likerace
for it since the same functionality can be achieved viaAsync
combinators andAsync.run
to obtain aFiber
. I hadn't noticed thatfromCompletionStage
is still inFiber
and using an old method naming pattern with aFiber
suffix.Solution
Move the method to
Async
and removefromCompletionStageFiber
.