Closed
Conversation
conectado
reviewed
Jun 10, 2025
| But it's another weapon in your arsenal which should be considered. So next time you are reaching for `Arc<Mutex<T>>` in async code, consider if it could instead be written in `Poll`-style. | ||
| But it's another tool in your arsenal which should be considered. So next time you are reaching for `Arc<Mutex<T>>` in async code, consider if it could instead be written in `Poll`-style. | ||
|
|
||
| <!-- I was never a fan of the term "poll-style". All futures are poll-style, the difference is whether you write them yourself or the compiler does it for you. I think "hand-rolled" futures might be a better term? |
Owner
There was a problem hiding this comment.
Ah, yes hand-rolled is a much better term.
conectado
reviewed
Jun 10, 2025
|
|
||
| <!-- I was never a fan of the term "poll-style". All futures are poll-style, the difference is whether you write them yourself or the compiler does it for you. I think "hand-rolled" futures might be a better term? | ||
|
|
||
| In general, I think you might want to come up with a more complex example. Many problems can be solved with Rust's built-in `async` lowering. Even if you have shared state between them, they can often be modelled as multiple streams of events that all get "merged". In your case, you could merge both intervals into a single stream, poll / await that and then update the state on each event. That way, you'd also have a single owner of the state again and Rust will happy compile it. |
Owner
There was a problem hiding this comment.
Ah you're right, it feels too artificial here that both "events" update the state when it could be trivially extracted from within the futures. I need to spend some time coming up with a better example.
Thanks for this feedback! It's super useful
Owner
|
Thanks again a lot for the feedback, it's been beyond invaluable! <3 I've been thinking through it a lot these weeks and I've come up with #31 (WIP right now) in place of this article. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.