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

Skip to content

Conversation

@adamgfraser
Copy link
Contributor

Resolves #1697.

@adamgfraser adamgfraser requested a review from iravid September 21, 2019 00:39
reserve.flatMap {
case Reservation(acquire, release) =>
Ref.make(true).map { finalize =>
val canceler = (release(Exit.interrupt) *> finalize.set(false)).uninterruptible
Copy link
Member

Choose a reason for hiding this comment

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

Oh right I forgot about release using an Exit[_, _]. How about we do 2 variants - withEarlyReleaseExit(Exit[_, _] => URIO) and withEarlyRelease?

I was going back and forth on defaulting to Exit.interrupt but I'm convinced this is good. Let's just add a note about that on the scaladoc.

* A more powerful version of `withEarlyRelease` that allows specifying an
* exit value in the event of early release.
*/
final def withEarlyReleaseExit(exit: Exit[_, _]): ZManaged[R, E, (URIO[R, _], A)] =
Copy link
Member

Choose a reason for hiding this comment

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

How about renaming both to earlyRelease and earlyReleaseWith, this seems to be more in line with other combinators that have a more powerful version.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think maybe withEarlyRelease indicates more clearly that it is giving you an option to do early release but not actually doing it? And we do have other Exit variants like finalizer and finalizerExit. But that is super subjective. I'm fine with either one. @iravid What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

withEarlyRelease is probably more accurate as it "adds" the option to release early

@iravid iravid merged commit 910b64a into zio:master Sep 21, 2019
@adamgfraser adamgfraser deleted the 1697 branch September 22, 2019 23:00
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#withEarlyRelease

3 participants