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

Turn lite::types::Requester into an async trait #170

Closed
romac opened this issue Mar 10, 2020 · 0 comments · Fixed by #171
Closed

Turn lite::types::Requester into an async trait #170

romac opened this issue Mar 10, 2020 · 0 comments · Fixed by #171
Labels
enhancement New feature or request

Comments

@romac
Copy link
Member

romac commented Mar 10, 2020

Requester not being an async trait forces implementations to block on RPC queries, eg. by spawning a new executor, which is undesirable considering that we eventually want the whole codebase to play nice with async/.await, and not unnecessarily block the enclosing task.

This can be accomplished with async-trait crate, which turns async fns within traits and their implementations into plain functions returning Pin<Box<dyn Future<Output = T + ...>>>.

The obvious drawback of this approach is that these async Fns now allocate memory on the heap. Hopefully, the language will soon stabilize the feature, which will help us get rid of these undesirable heap allocations.

@romac romac added the enhancement New feature or request label Mar 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant