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

Tokio integration #267

Closed
DemiMarie opened this issue Dec 19, 2018 · 8 comments
Closed

Tokio integration #267

DemiMarie opened this issue Dec 19, 2018 · 8 comments

Comments

@DemiMarie
Copy link

It would be very nice to be able to use smoltcp with the Tokio ecosystem. For me, the first use case that comes to mind is extremely high-performance servers that use kernel bypass networking, but there are probably many, many others.

@whitequark
Copy link
Contributor

Sure. I am not personally invested in Tokio so I will not work on it myself.

@Hirrolot
Copy link

This is probably a good idea, but it's strange that high-level abstractions like futures will be in such a low-level crate.

@whitequark
Copy link
Contributor

I think futures are pretty low level, it's just another way to represent control flow. In general, microcontroller firmware often greatly benefits from using async/await-like control flow rather than threads; there are many coroutine replacements (not really implementations) for C specifically for this task.

@Hirrolot
Copy link

Hirrolot commented Oct 9, 2019

I agree with you.

@stlankes
Copy link
Contributor

stlankes commented Feb 4, 2020

Do you still working on a Tokio integration? Do you have already a test example?

@dingelish
Copy link

very interested in tokio integration as well. do you need help?

@whitequark
Copy link
Contributor

Sure, would be helpful to have even a proof of concept.

@Dirbaio
Copy link
Member

Dirbaio commented Dec 26, 2020

I'd love to see async/await support in smoltcp too!

From some experiments I've done (#382), I believe the best approach is to:

  • Add support in smoltcp to associate Wakers to sockets.
  • Leave everything else to external higher-level crates.

The higher-level crates would implement wrappers for the smoltcp types that implement the desird async traits (AsyncRead, AsyncWrite, Stream for UDP packets..?).

I believe this is the best way to go, because:

  • It is not clear which traits should smoltcp implement:
    • The std ecosystem has multiple competing incompatible traits, mainly tokio and futures.
    • The no_std ecosystem hasn't converged on any standard io traits yet. The tokio and futures traits aren't no_std compatible.
  • There are non-trivial tradeoffs when implementing async support: how are sockets allocated, is there a single global tcp/ip stack or multiple, how are lifetimes handled.

Closing this as we won't be integrating with Tokio specifically, but the PR adding Waker support is coming very soon! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

6 participants