-
Notifications
You must be signed in to change notification settings - Fork 67
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
Add Resource.toManagedZIO, add Concurrent.continual implementation, fix toManaged #109
Conversation
neko-kai
commented
Nov 16, 2019
- remove unused Util.fromFuture – superseded by ZIO.fromFuture
- remove redundant accessM/provide in Concurrent.cancelable
- remove redundant private classes CatsMonad & CatsEffect
- Fix Exit/ExitCase handling in toManaged/toResource - new makeCase/makeExit clauses in CatZManagedSyntaxSpec didn't pass before
- minor code cleanups
…ix toManaged * remove unused Util.fromFuture – superseded by ZIO.fromFuture * remove redundant accessM/provide in Concurrent.cancelable * remove redundant private classes CatsMonad & CatsEffect * Fix Exit/ExitCase handling in toManaged/toResource - new makeCase/makeExit clauses in CatZManagedSyntaxSpec didn't pass before * minor code cleanups
@@ -26,6 +25,14 @@ class CatsZManagedSyntaxSpec extends Specification with AroundTimeout with Defau | |||
calls finalizers should not run if exception is thrown in acquisition $toManagedFinalizersExceptionAcquisition | |||
composing with other managed should calls finalizers in correct order $toManagedComposition | |||
|
|||
toManagedZIO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great to see the additional coverage!
fa.ensuring(finalizer.orDie) | ||
|
||
override final def continual[A, B](fa: RIO[R, A])(f: Either[Throwable, A] => RIO[R, B]): RIO[R, B] = | ||
ZIO.uninterruptibleMask(_(fa).either.flatMap(f)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think this is correct from inspecting the implementation of Concurrent.continual
. I thought at first that f
shouldn't run uninterruptibly, but in Concurrent.continual
it is executed under guaranteeCase
which (I assume) runs a finalizer uninterruptibly.
}) | ||
.uninterruptible | ||
) | ||
ZManaged(L.liftIO(res.map { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice simplification here
final class CatsIOResourceSyntax[F[_], A](private val resource: Resource[F, A]) extends AnyVal { | ||
|
||
def toManagedZIO[R, E <: Throwable](implicit ev: Resource[F, A] <:< Resource[ZIO[R, E, ?], A]): ZManaged[R, E, A] = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍