Skip to content

Instantly share code, notes, and snippets.

@natansil
Created May 22, 2021 16:58
Show Gist options
  • Save natansil/2eafa1cf72967237f767734a98094850 to your computer and use it in GitHub Desktop.
Save natansil/2eafa1cf72967237f767734a98094850 to your computer and use it in GitHub Desktop.
object RuntimeOps {
implicit class RuntimeEnvOps[R <: Has[_]](val runtime: zio.Runtime[R]) extends AnyVal {
def withFiberTracking(implicit tag: zio.Tag[R]): zio.Runtime[R with FiberTracking] = {
val supervisor = runtime.unsafeRunTask(Supervisor.track(weak = false))
runtime
.mapPlatform(_.withSupervisor(supervisor))
.map(_.union[FiberTracking](FiberTracking.make(supervisor)))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment