-
Notifications
You must be signed in to change notification settings - Fork 443
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
Async/await waker support. #394
Merged
Conversation
This file contains 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
whitequark
reviewed
Dec 27, 2020
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM other than inline comments. Nice work!
stlankes
added a commit
to stlankes/hermit-rs
that referenced
this pull request
Mar 22, 2021
smoltcp 0.7 provides async/await waker support (smoltcp-rs/smoltcp#394). I followed the example implementation https://github.com/embassy-rs/embassy/tree/net/embassy-net to add waker support in hermit-sys. However, hermit-sys can be used in a multi-threaded applications. Consequently, the implementation must be thread safed. In addition, we still have an "network thread", which is wakeup by an interrupt. The thread wakeups all waiting future. If no future is available, the thread calls directly the IP stack.
stlankes
added a commit
to stlankes/hermit-rs
that referenced
this pull request
Mar 30, 2021
smoltcp 0.7 provides async/await waker support (smoltcp-rs/smoltcp#394). I followed the example implementation https://github.com/embassy-rs/embassy/tree/net/embassy-net to add waker support in hermit-sys. However, hermit-sys can be used in a multi-threaded applications. Consequently, the implementation must be thread safed. In addition, we still have an "network thread", which is wakeup by an interrupt. The thread wakeups all waiting future. If no future is available, the thread calls directly the IP stack.
Looks like the AsyncBufRead and AsyncWrite example for |
stlankes
added a commit
to stlankes/hermit-rs
that referenced
this pull request
Jun 25, 2021
smoltcp 0.7 provides async/await waker support (smoltcp-rs/smoltcp#394). I followed the example implementation https://github.com/embassy-rs/embassy/tree/net/embassy-net to add waker support in hermit-sys. However, hermit-sys can be used in a multi-threaded applications. Consequently, the implementation must be thread safed. In addition, we still have an "network thread", which is wakeup by an interrupt. The thread wakeups all waiting future. If no future is available, the thread calls directly the IP stack.
mkroening
pushed a commit
to mkroening/rusty-hermit
that referenced
this pull request
Jun 29, 2021
smoltcp 0.7 provides async/await waker support (smoltcp-rs/smoltcp#394). I followed the example implementation https://github.com/embassy-rs/embassy/tree/net/embassy-net to add waker support in hermit-sys. However, hermit-sys can be used in a multi-threaded applications. Consequently, the implementation must be thread safed. In addition, we still have an "network thread", which is wakeup by an interrupt. The thread wakeups all waiting future. If no future is available, the thread calls directly the IP stack.
stlankes
added a commit
to stlankes/hermit-rs
that referenced
this pull request
Aug 2, 2021
smoltcp 0.7 provides async/await waker support (smoltcp-rs/smoltcp#394). I followed the example implementation https://github.com/embassy-rs/embassy/tree/net/embassy-net to add waker support in hermit-sys. However, hermit-sys can be used in a multi-threaded applications. Consequently, the implementation must be thread safed. In addition, we still have an "network thread", which is wakeup by an interrupt. The thread wakeups all waiting future. If no future is available, the thread calls directly the IP stack.
stlankes
added a commit
to stlankes/hermit-rs
that referenced
this pull request
Aug 2, 2021
smoltcp 0.7 provides async/await waker support (smoltcp-rs/smoltcp#394). I followed the example implementation https://github.com/embassy-rs/embassy/tree/net/embassy-net to add waker support in hermit-sys. However, hermit-sys can be used in a multi-threaded applications. Consequently, the implementation must be thread safed. In addition, we still have an "network thread", which is wakeup by an interrupt. The thread wakeups all waiting future. If no future is available, the thread calls directly the IP stack.
stlankes
added a commit
to hermit-os/hermit-rs
that referenced
this pull request
Aug 7, 2021
smoltcp 0.7 provides async/await waker support (smoltcp-rs/smoltcp#394). I followed the example implementation https://github.com/embassy-rs/embassy/tree/net/embassy-net to add waker support in hermit-sys. However, hermit-sys can be used in a multi-threaded applications. Consequently, the implementation must be thread safed. In addition, we still have an "network thread", which is wakeup by an interrupt. The thread wakeups all waiting future. If no future is available, the thread calls directly the IP stack.
stlankes
added a commit
to hermit-os/hermit-rs
that referenced
this pull request
Aug 7, 2021
smoltcp 0.7 provides async/await waker support (smoltcp-rs/smoltcp#394). I followed the example implementation https://github.com/embassy-rs/embassy/tree/net/embassy-net to add waker support in hermit-sys. However, hermit-sys can be used in a multi-threaded applications. Consequently, the implementation must be thread safed. In addition, we still have an "network thread", which is wakeup by an interrupt. The thread wakeups all waiting future. If no future is available, the thread calls directly the IP stack.
This example link shouldn't break unless they re-write history: |
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.
This adds
register_recv_waker
andregister_send_waker
methods to all socket types.This is the minimum required changes to smoltcp to support being used in async/await code. This opens the door for higher-level crates that expose wrappers implementing async traits like AsyncRead/AsyncWrite, Future, Stream...
I believe this is the best way to go, because:
std
ecosystem has multiple competing incompatible traits, mainlytokio
andfutures
.no_std
ecosystem hasn't converged on any standard io traits yet. Thetokio
andfutures
traits aren'tno_std
compatible.By delegating these choices to external crates, smoltcp can stay un-opinionated.
There's an example of using this to implement AsyncBufRead and AsyncWrite in
embassy
here. Wrappers for thetokio
orfutures
traits would look very similar. The use ofunsafe
there is not necessary in theory, AsyncRead and AsyncWrite can be implemented in 100% safe Rust. AsyncBufRead probably will require unsafe in most cases, unfortunately.Previously discussed on #382 and #267 .