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

Undocumented and unintuitive behaviour of JoinHandle::abort #1644

Open
Hawk777 opened this issue Jan 31, 2025 · 1 comment
Open

Undocumented and unintuitive behaviour of JoinHandle::abort #1644

Hawk777 opened this issue Jan 31, 2025 · 1 comment

Comments

@Hawk777
Copy link
Contributor

Hawk777 commented Jan 31, 2025

I’m not sure if this is something that is intended behaviour but would be worth documenting better, or something that is not intended behaviour and would be worth fixing, but here goes.

When you call glib::JoinHandle::abort (not to be confused with gio::JoinHandle; I’m speaking of the futures one), it calls g_source_destroy, which stops the future from being scheduled on the CPU (guaranteed immediately, as far as I can tell, if you’re calling abort from the same thread on which the future normally runs). However, while it destroys the source, it does not unref the source, which means the future is not actually dropped (because the future is held inside the TaskSource), which means any objects held inside the future (e.g. GioFutures for ongoing async operations) are also not dropped, which means those async operations carry on going. It seems that the future is not actually dropped until the JoinHandle is dropped. This seems really unintuitive: I would definitely have expected JoinHandle::abort to drop the future (either within itself or on the next iteration of the main loop).

This might be somewhat related to GH-46 but it’s not quite the same thing.

@sdroege
Copy link
Member

sdroege commented Jan 31, 2025

That indeed seems problematic and something to look into fixing.

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

No branches or pull requests

2 participants