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

Release handle when cancellation is requested #521

Merged
merged 1 commit into from
Jan 25, 2024

Conversation

LucianoPC
Copy link
Contributor

@LucianoPC LucianoPC commented Nov 22, 2023

Hi, I would like to release the asset on handle when the cancellation token is requested

@@ -171,6 +172,10 @@ void Continuation(AsyncOperationHandle _)
completed = true;
if (cancellationToken.IsCancellationRequested)
{
If (handle.IsValid())
Copy link
Contributor

@hadashiA hadashiA Jan 25, 2024

Choose a reason for hiding this comment

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

Syntax error seems to occur due to typo.

Suggested change
If (handle.IsValid())
if (handle.IsValid())

@hadashiA
Copy link
Contributor

Seems to need a little adjustment.

  • It may not take into account if CancellationToken.Register is used (cancelImmediately = true).
  • It seems that handle.Completed -= would error out that the reference count has reached 0. It would be safe to have an IsValid check here as well.

@hadashiA
Copy link
Contributor

I created #536 while testing this pr and have a few commits added.
Any comments are welcome.

@LucianoPC
Copy link
Contributor Author

I created #536 while testing this pr and have a few commits added. Any comments are welcome.

It seems very nice, this "autoReleaseWhenCancelled" works good, thanks

@neuecc neuecc merged commit 36ac086 into Cysharp:master Jan 25, 2024
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