Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@vvlevykin
Copy link
Contributor

@vvlevykin vvlevykin commented Jul 25, 2019

Resolves #1231.

iravid
iravid previously approved these changes Jul 27, 2019
Copy link
Member

@iravid iravid left a comment

Choose a reason for hiding this comment

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

Thank you @vvlevykin, this looks good and would be a great addition to ZManaged!

@iravid
Copy link
Member

iravid commented Jul 27, 2019

This needs a rebase and a fix to mdoc and should be good to go!

@vvlevykin
Copy link
Contributor Author

This example from the doc becomes clunky, what do you suggest instead of ??? here?

val data: IO[IOException, String] = for {
  p <- Promise.make[IOException,File]
  res = Reservation(openFile("x", p), _ => closeFile(p))
  result <- (for {
      fiber  <- res.acquire.fork
      ex     <- fiber.interrupt
      data   <- ex.toEither.fold(e => IO.fail(new InterruptedIOException("Stop!")), file => readFile(file))
    } yield data).ensuring(res.release(???))
} yield result

@iravid
Copy link
Member

iravid commented Jul 30, 2019

@vvlevykin I'd just delete the entire section on that. Reservation doesn't have any value outside the context of ZManaged and that example does not make sense to me.

@iravid iravid merged commit 4b98cbe into zio:master Aug 1, 2019
@iravid
Copy link
Member

iravid commented Aug 1, 2019

Nicely done - thanks @vvlevykin!

ghostdogpr pushed a commit to ghostdogpr/scalaz-zio that referenced this pull request Aug 5, 2019
…io#1232)

* Add ZManaged.makeExit that allows to handle `Exit` by the finalizer.

* Update ZStream.

* Add tests.

* Fix formatting.
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.

Add ZManaged.makeExit

2 participants