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

Resolve issue where inefficient usage of future::then is common #407

Open
camio opened this issue May 25, 2022 · 1 comment
Open

Resolve issue where inefficient usage of future::then is common #407

camio opened this issue May 25, 2022 · 1 comment

Comments

@camio
Copy link
Contributor

camio commented May 25, 2022

Within a single expression, future::then is frequently used multiple times with relatively fast pieces of code that do not justify the overhead of yielding control to the event loop. This anti-pattern is present in examples within stlab's documentation and is pervasive in actual usage. The extensive usage is likely due to an enhanced clarity of the resulting code.

This task is to come up with a mitigation strategy for this anti-pattern.

Acceptance criteria

  • A mitigation strategy has consensus within the stlab team
  • The mitigation strategy is executed

Possible solutions

  • Modify documentation to warn against this kind of usage
  • Incorporate ideas from the Sender/Receiver model which mitigates this by separating task execution from task graph building
@FelixPetriconi
Copy link
Member

I see your point.
I use this pattern often to decouple file I/O from the UI, which makes sense from my point of view.
I think it would be good to give the user a hint of how big the task should be that is handled within a single continuation.

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