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

Add Resource.toManagedZIO, add Concurrent.continual implementation, fix toManaged #109

Merged
merged 5 commits into from
Nov 17, 2019

Conversation

neko-kai
Copy link
Member

  • 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
iravid
iravid previously approved these changes Nov 17, 2019
@@ -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
Copy link
Member

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))
Copy link
Member

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 {
Copy link
Member

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] = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@neko-kai neko-kai merged commit 3373d0e into zio:master Nov 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants