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

Resource.allocated #419

Merged
merged 2 commits into from Nov 21, 2018
Merged

Conversation

SystemFw
Copy link
Contributor

No description provided.

@codecov-io
Copy link

codecov-io commented Nov 19, 2018

Codecov Report

Merging #419 into master will decrease coverage by 0.21%.
The diff coverage is 90%.

@@            Coverage Diff            @@
##           master    #419      +/-   ##
=========================================
- Coverage   87.52%   87.3%   -0.22%     
=========================================
  Files          69      69              
  Lines        1820    1828       +8     
  Branches      189     189              
=========================================
+ Hits         1593    1596       +3     
- Misses        227     232       +5

@@ -137,6 +137,70 @@ sealed abstract class Resource[F[_], A] {
*/
def flatMap[B](f: A => Resource[F, B]): Resource[F, B] =
Bind(this, f)

/**
Copy link
Contributor

Choose a reason for hiding this comment

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

💯 This is great doc

case (_, ExitCase.Completed) =>
F.unit
case ((_, release), ec) =>
release(ec)
Copy link
Member

Choose a reason for hiding this comment

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

At a cursory look, what jumps out at me is that you're calling release here, irregardless of the ExitCase. And I thought the purpose of allocate is to not call release, but to save it for later.

Am I missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's a bracketCase, not bracket. I'm calling release if the outer F fails or is interrupted during the process of acquiring resources, but if it completes properly, I then return the finaliser.
The rationale is here https://github.com/typelevel/cats-effect/pull/419/files#diff-ca16b2d95f362b8bc9b6c405f858be0cR146

Copy link
Member

Choose a reason for hiding this comment

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

Ah, sorry, this is in case it isn't Completed.

@alexandru
Copy link
Member

PR looks good to me. Is it done?

@SystemFw
Copy link
Contributor Author

Code wise, I think it is. I would like some more tests but writing them appears tricky, maybe we can merge and iterate after?

@alexandru alexandru changed the title WIP: Resource.allocated Resource.allocated Nov 21, 2018
@alexandru alexandru merged commit 09b89bc into typelevel:master Nov 21, 2018
@alexandru
Copy link
Member

OK 🙂

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.

None yet

4 participants