8000 [core] move fromCompletionStage from Fiber to Async by fwbrasil · Pull Request #1195 · getkyo/kyo · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[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

Merged
merged 4 commits into from
May 21, 2025
Merged

Conversation

fwbrasil
Copy link
Collaborator

Problem

Fiber is a low-level effect with complex semantics for newcomers. Its functionality is essential for integrations and more low-level code but Async 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 like race for it since the same functionality can be achieved via Async combinators and Async.run to obtain a Fiber. I hadn't noticed that fromCompletionStage is still in Fiber and using an old method naming pattern with a Fiber suffix.

Solution

Move the method to Async and remove fromCompletionStageFiber.

@@ -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 =
Copy link
Collaborator

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).

@fwbrasil fwbrasil merged commit a752eb5 into main May 21, 2025
3 checks passed
@fwbrasil fwbrasil deleted the fromCompletionStage branch May 21, 2025 05:56
@@ -1028,7 +1028,7 @@ class ChannelTest extends Test:
latch.await.andThen(channel.close)
)
_ <- latch.release
_ <- channel.drain
_ <- Abort.run(channel.drain)
Copy link
Collaborator Author
@fwbrasil fwbrasil May 21, 2025

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

fwbrasil added a commit that referenced this pull request May 22, 2025
### 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.
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

Successfully merging this pull request may close these issues.

2 participants
0