Skip to content

Should we provide our own join and select, or leave it to users? #1098

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

Closed
ColinWttt opened this issue Mar 25, 2025 · 4 comments
Closed

Should we provide our own join and select, or leave it to users? #1098

ColinWttt opened this issue Mar 25, 2025 · 4 comments

Comments

@ColinWttt
Copy link
Contributor

ColinWttt commented Mar 25, 2025

Since PR #1043, we now have an async runtime. I tried using futures::join! and futures::select!, and both worked well. I also tried futures-lite zip and or — lightweight alternatives to join and select that support only two futures. (itest: futures and futures-lite )

join and select seem highly useful in game development, yet Godot lacks similar built-in functionality.

For example, wait for multiple tween animations to complete. Alternatively, stop waiting if the user doesn’t press a key within 5 seconds.

Will gdext consider implementing them in the future, or should this be left to users, similar to how rand is handled?

@ColinWttt ColinWttt changed the title Should we provide our own join! and select, or leave it to users? Should we provide our own join and select, or leave it to users? Mar 25, 2025
@TitanNano
Copy link
Contributor

TitanNano commented Mar 26, 2025

All of these can easily be pulled in via futures-util, so I don't really see a point in reimplementing them. We could consider re-exporting future-utils from godot but I don't actually see an advantage in that.

@ColinWttt ColinWttt closed this as not planned Won't fix, can't repro, duplicate, stale Mar 27, 2025
@Bromeon
Copy link
Member

Bromeon commented Mar 27, 2025

It might still be worth documenting that futures-util can be used for join and select, what do you guys think?
We could then link to that crate from our API docs.

What would be a good place? Maybe TaskHandle?

@TitanNano
Copy link
Contributor

Maybe in the module description of godot::task?

@Bromeon
Copy link
Member

Bromeon commented Mar 27, 2025

Also possible. Over time, we could then expand that with some examples.

The standard library typically does this too:

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

3 participants