-
Notifications
You must be signed in to change notification settings - Fork 88
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
Feature Request: non-blocking recv() #16
Comments
@tstellanova ping |
@wucke13 feel free to submit a pull request |
I have looked into this a bit more. AFAIK, there are two ways of accomplishing this:
The correct way of doing this involves re-implementing parts of the MAVLink parser. Any chances that you will look into this? Can you confirm my understanding of the possible solutions, or is there a neat way that I'm missing out on? |
Sounds like you’re making progress on a design.
Agreed the second approach seems more beneficial than the first.
I’m unlikely to have time to add features in the next few months, and admittedly I have not kept up with the latest async features in rust, so may not be the best person to advise on that. Last I heard, @podhrmic was working on a significant refactor, but I don’t know where that’s at.
… On Dec 26, 2019, at 10:35 AM, wucke13 ***@***.***> wrote:
I have looked into this a bit more. AFAIK, there are two ways of accomplishing this:
ugly: spawning a new thread, blocking recv() in that thread, push to MPSC, use MPSC try_recv() to get async behavior. That's what I'm currently doing as a hot fix.
correct: Adding state to read_versioned_msg(). Detect if buffer is not big enough to parse the message, and return std::io::ErrorKindWouldBlock in that case. Preserve the so far consumed bytes, as they might be part of a valid message. That way it becomes trivial to implement the actual try_recv(). One could orient at tokio's codec trait, for the implementation.
The correct way of doing this involves re-implementing parts of the MAVLink parser. Any chances that you will look into this? Can you confirm my understanding of the possible solutions, or is there a neat way that I'm missing out on?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Hi @wucke13 ! That being sad, feel free to submit a PR with your solution, just make sure it is properly feature gated with @tstellanova I got kind of stuck typechecking enums and implementing a set of sensible quickcheck tests, then I ran out of time. So it is kind of half finished at the moment:-/ |
I would oppose to using futures for this. From recent experiment I took away that futures are only beneficial when one build complex dependencies on them. For a simple "give it to me, if and only if its ready" they are not a good fit. I would therefore still prefer the Also, I think I'm still not convinced that my understanding is sufficient to make a PR for this, we will see 😄 |
Just to update this issue, I'm working to add such feature, probably a PR should be ready in a couple of days, the ideas is to implement something like |
@patrickelectric That is very good news! However, please note: Since I wrote my comment, futures came a long way! Especially with
Internally, What do you think about this? |
It would be nice to have a way of non-blocking
recv()
. I think there is many applications for it, just like instd::sync::mpsc::Receiver
.The text was updated successfully, but these errors were encountered: