Adding future and deferred documentation#143
Conversation
There was a problem hiding this comment.
Thanks a lot for your contribution! I think this is a great addition to the book.
Some comments:
-
Title should probably be "Async programming" or so; there may be more additions in the future.
-
Formatting and linting:
- Please use the available line lenghts of 130-150 characters, see how other pages do it.
- Lints should pass, see https://github.com/godot-rust/book#formatting-and-linting.
- Same for license.
- If possible, run a spellchecker or AI review, there are a few grammar/orthography mistakes. (To be clear I'm not suggesting to let AI rewrite things, the human formulations are great. More about giving feedback so we don't have to manually go through each instance).
-
The "Using the Godot API" section is for very basic things, while this is rather advanced. You're also referencing concepts like signals that haven't yet been explained. For now I would move this down to the "Recipes" section -- we should probably reorganize that to "Advanced topics" or so later.
| // FAIL! While you can have multiple smart pointers, you can't bind | ||
| // multiple items. This will not release an existing guard. | ||
| let gd = self.object_to_owned(); |
There was a problem hiding this comment.
Please only use exclamation marks in rare circumstances when attention is absolutely required. Inflationary use seems overly dramatic and can disrupt the reading flow. This also applies to many other places on the page. I think most of the current ! could just be . instead.
Here it's also not clear what "FAIL" even means. Does it not compile? Crash at runtime? Comments should be more descriptive.
Furthermore, object_to_owned is an extremely niche API mostly used by signal internals. Can this problem be demonstrated by a more common API, that the user is likely to have come across by the time of reading this page?
There was a problem hiding this comment.
I think so. There is to the to_gd method. Or alternatively we can drop this section if you don't think it is needed.
| ```admonish warning title="Joining threads" | ||
| Because the Godot engine is running separate of Rust, you will want | ||
| to be thoughtful on using any native Rust calls for joining async calls | ||
| to avoid a deadlock freezing your program. | ||
| ``` |
There was a problem hiding this comment.
This is very vague:
- First, the causality "Rust + Godot separate" -> "deadlock" is misleading, what's the logical step here?
- This doesn't offer any concrete advice on avoiding deadlocks. "Be thoughtful" is not really helpful 🙂
Since there is an example following this, shouldn't this be regular text rather than an admonition? The text could then introduce the example rather than make vague statements.
There was a problem hiding this comment.
Let's try to regular text that also crossed my mind.
There was a problem hiding this comment.
Because the Godot engine is running separate of Rust
This is not very accurate. Both Rust and Godot run in the same process and even in the same thread. This is why the future can't make any progress when you block the thread waiting for the future.
There was a problem hiding this comment.
Yup, thank you for pointing this out! I have unverified word mush here that I will iterate on and add this.
Speaking of broken promises, my screenshot example also isn't being fulfilled yet. I don't use the word set_deferred anywhere in this documentation so it will still show as not found.
|
@Bromeon It sounds like you are interested in this section, so I'll give this PR a clean up while also adding your suggestions. |
|
I'm hoping to have a new iteration out on this this evening JST. @Bromeon Regarding |
As mentioned here, does this really add something in the context of async programming, or is it more distracting? The subtleties of signal APIs are already explained in quite some detail in API docs, including In other words, the book's purpose is to be an introductory guide / tutorial for people learning the library, and it does not strive to exhaustively cover the API. That part is the responsibility of our API docs. Please also fix the CI, then we can give this a review 🙂 |
I have no pride issues if the outcome of this PR is to close it. I think the other possible outcome is that this documentation doesn't belong here. Let me post what I think are the for and against argument points of this PR because I think it will help the conversation. ArgumentsAgainst Argument Points
For Argument Points
Potential ApproachesWhile it is possible to create a separate section in the docs, I think it is also possible to augment existing documentation similar to what we did with the api docs. For example,
The API docs should probably also mention and link Potential Plans of Action
Thoughts? |
To be clear, I was referring to specific signal APIs, not async. I agree that a page on async programming makes sense. But for people that are new to async (maybe also haven't used it in GDScript before), the topic is already complex enough, so discussing detailed signal connection nuances on the same page may not be in anyone's interest.
I don't think this is a good criterion. There are plenty of topics that are Rust-specific and do not exist for Godot itself (the whole
I agree, this would be nice. Adding method-specific docs is already planned, but the mechanism in godot-codegen is not yet implemented. Once it is, this link to
I'm happy to continue this PR, but I would remove signal specifics that are not relevant for the understanding of |
|
Thank you! I think this is enough feedback to do another iteration and clean this PR up. |
|
@Bromeon I have applied the feedback and made the CI pass. I need to give the documentation one more look over for spelling/phasing before bringing this out of draft. In my college days I learned that in writing it is more important to get your ideas together to verify them before digging into the weeds of spelling. The reason is you lose focus of the whole. Now in my later years, I also value it in that I don't waste as much time verifying spellchecking and style until I know I have something worth finishing. I don't have as much time nowadays as when I was in my 20s. |
|
Regarding not using the timer signal and moving it to a recipe, I'm still brain storming on what to replace the async code with that would be simpler and obvious. |
96be2a3 to
60c323a
Compare
|
@Bromeon @TitanNano Thank you so much for the wait, this PR is now officially read for final review. |
7332cd3 to
df24ed3
Compare

The problem this PR is trying to solve:
Example:
The proposed solution
This PR proposes a new
Futures and Deferred Functionssection to help explain async in rust-godot. There was a lot of work to related functionality for typesafe deferred function calls and futures... we should show it off in the documentation!Feedback welcome! This is just a draft for now! Thank you for your time!