Skip to content

Commit

Permalink
[kyo-zio] use: Fiber.Runtime.UnsafeAPI#interrupt method (#833)
Browse files Browse the repository at this point in the history
  • Loading branch information
hearnadam authored Nov 10, 2024
1 parent 327a190 commit b209b7d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
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.

0 comments on commit b209b7d

Please sign in to comment.