-
Notifications
You must be signed in to change notification settings - Fork 536
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[F, A]#memoize
releases right after first use
#3079
Comments
Okay @SystemFw, you can say I told you so. 😛 This is a known issue. Or rather, it's actually defined this way in general. The problem is that this definition of memoize follows directly from the definition of scoping in Resource itself. It isn't really "solvable" per se. The long and short of the problem is the use of |
Yeah, why is that? Seems straightforward enough to override the implementation to do the right thing, I tried this in #3080. |
Ah, this issue looks like a dupe of #1620. |
@djspiewak, I'm not sure I follow. :( As for implementation, semaphore + ref counter could solve #3080 issue of allocation on release. |
I mean, for every And if we have |
Scastie link: https://scastie.scala-lang.org/wxfOvT64RDSGkjRfeAqWgA
Memoized resource allocates just before the first use (as expected), but releases right after it neither holding resource until 'memo release' nor allocating anew before second usage:
Cats-Effect 3.3.13, Scala 2.13.8
The text was updated successfully, but these errors were encountered: