-
Couldn't load subscription status.
- Fork 1.4k
Uncurried versions of 'bracket' and 'bracketExit' #617
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
Conversation
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.
Looks great to me! You preserved all the code from the old versions, right? Just moved them over?
Also, would be nice to have a little code that shows the uncurried ones infer (somewhat).
|
@LGLO Thanks a lot for doing this! Let's merge after the build is passing. |
|
👍 I'll try to retain scaladoc link, although it's tricky. |
|
@LGLO Would love to get this in as soon as the build passes! |
|
@jdegoes I've run this benchmark: 5 iterations, 30 seconds each (to let GC work) and observed no difference: I cannot prove this PR helps in anything. |
|
@LGLO I am ok merging, actually, because in the best case the JIT can eliminate short-lived allocations, but that depends a lot on the code being run, version of JRE, etc. At least with these versions, we have a guarantee of minimal allocation. What do you think? |
27ba045 to
4c0342a
Compare
| } yield (result must_=== 0L) and (released must_=== true) | ||
| } | ||
|
|
||
| object UncurriedBracketCompilesRegardlessOrderOfEAndRTypes { |
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.
I don't really know where to place these if-compiles-works tests.
| * Finalizers offer very powerful guarantees, but they are low-level, and | ||
| * should generally not be used for releasing resources. For higher-level | ||
| * logic built on `ensuring`, see [[ZIO#bracket]]. | ||
| * logic built on `ensuring`, see `ZIO#bracket`. |
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.
I'm sorry for this one, but scaladoc finds two bracket methods now and I cannot find method when signature contains type bounded by type LowerR declared inside ZIO.
|
Okey! |
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.
Looks great!
* Uncurried versions of 'bracket' and 'bracketExit' * Fixed doc and added specs
I open this to have version of
bracketsuitable for hot-path in performance sensitive applications.