From b209b7db3cee9dc9dfe808fd40b473b744fb9c7a Mon Sep 17 00:00:00 2001 From: Adam Hearn <22334119+hearnadam@users.noreply.github.com> Date: Sat, 9 Nov 2024 22:49:18 -0500 Subject: [PATCH] [kyo-zio] use: `Fiber.Runtime.UnsafeAPI#interrupt` method (#833) --- kyo-zio/shared/src/main/scala/kyo/ZIOs.scala | 8 +++++--- kyo-zio/shared/src/main/scala/zio/FiberInterop.scala | 5 ----- 2 files changed, 5 insertions(+), 8 deletions(-) delete mode 100644 kyo-zio/shared/src/main/scala/zio/FiberInterop.scala diff --git a/kyo-zio/shared/src/main/scala/kyo/ZIOs.scala b/kyo-zio/shared/src/main/scala/kyo/ZIOs.scala index 301f35e19..26f6a5bbc 100644 --- a/kyo-zio/shared/src/main/scala/kyo/ZIOs.scala +++ b/kyo-zio/shared/src/main/scala/kyo/ZIOs.scala @@ -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 @@ -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 } } diff --git a/kyo-zio/shared/src/main/scala/zio/FiberInterop.scala b/kyo-zio/shared/src/main/scala/zio/FiberInterop.scala deleted file mode 100644 index 71731d929..000000000 --- a/kyo-zio/shared/src/main/scala/zio/FiberInterop.scala +++ /dev/null @@ -1,5 +0,0 @@ -package zio - -extension [E, A](fiber: Fiber.Runtime[E, A]) - def unsafeInterrupt()(using trace: Trace, u: Unsafe): Unit = - fiber.tellInterrupt(Cause.Interrupt(FiberId.None, StackTrace(FiberId.None, Chunk(trace))))