Skip to content
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

[kyo-zio] use: Fiber.Runtime.UnsafeAPI#interrupt method #833

Merged
merged 1 commit into from
Nov 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions kyo-zio/shared/src/main/scala/kyo/ZIOs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import kyo.kernel.*
import scala.concurrent.ExecutionContext
import scala.util.control.NonFatal
import zio.Exit
import zio.FiberId
import zio.Runtime
import zio.Unsafe
import zio.ZIO
Expand All @@ -19,17 +20,18 @@ object ZIOs:
* @return
* A Kyo effect that, when run, will execute the zio.ZIO
*/
def get[E, A](v: => ZIO[Any, E, A])(using Frame, zio.Trace): A < (Abort[E] & Async) =
def get[E, A](v: => ZIO[Any, E, A])(using f: Frame, t: zio.Trace): A < (Abort[E] & Async) =
IO.Unsafe {
Unsafe.unsafely {
import zio.unsafeInterrupt
given ce: CanEqual[E, E] = CanEqual.derived
val p = Promise.Unsafe.init[E, A]()
val f = Runtime.default.unsafe.fork(v)
f.unsafe.addObserver { (exit: zio.Exit[E, A]) =>
p.completeDiscard(exit.toResult)
}
p.onInterrupt(_ => discard(f.unsafeInterrupt()))
p.onInterrupt(_ =>
discard(f.unsafe.interrupt(zio.Cause.interrupt(FiberId.None, zio.StackTrace(FiberId.None, zio.Chunk(t)))))
)
p.safe.get
}
}
Expand Down
5 changes: 0 additions & 5 deletions kyo-zio/shared/src/main/scala/zio/FiberInterop.scala

This file was deleted.

Loading