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

Add a memoizedAcquire method to Resource #4105

Open
wants to merge 7 commits into
base: series/3.x
Choose a base branch
from

Conversation

satabin
Copy link

@satabin satabin commented Jul 18, 2024

As mentioned in #3890 (comment), this is the PR taking over #3890 to add a specialized version of memoized for Resource.

Ref #3513

val fa2 = F.uncancelable { poll =>
poll(allocatedCase).flatMap { case (a, r) => release.update(r :: _).as(a) }
}
Resource.makeCaseFull[F, F[B]](poll => poll(F.memoize(fa2)).map(_.widen)) { (_, exit) =>
Copy link
Author

Choose a reason for hiding this comment

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

@durban @armanbilge I applied the change here, to ensure acquisition will not be cancelled once F.memoize(fa2) has been successfully run. I tried to come up with a test to ensure the behavior but could not find any reliable way to write something that tries to cancel it at the right time.

Do you have an idea on how I could write such a test?

Copy link
Member

Choose a reason for hiding this comment

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

Do you have an idea on how I could write such a test?

#3425 is an example of a similar PR. Notice the special use of the test runtime.

TestControl.executeEmbed(go, IORuntimeConfig(1, 2))

Further reading:

Copy link
Author

Choose a reason for hiding this comment

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

Thanks, I will have a look at this.

@djspiewak djspiewak changed the title [Taking Over] Add a memoizedAcquire method to Resource Add a memoizedAcquire method to Resource Jul 18, 2024
@satabin
Copy link
Author

satabin commented Sep 17, 2024

I did not forget about this PR. Testing it is currently blocked by the PureConc finalizer problem (see #3430). As soon as there is a fix, I will design a test using it.

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.

3 participants