-
Notifications
You must be signed in to change notification settings - Fork 669
First stab at mio integration for alloc-free futures #5
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
Conversation
|
cc @carllerche |
|
Oh, and I should say that if we do want the whole readiness/completion concepts, obviously it should move into the futures library proper. |
| } | ||
| pub type IoFuture<T> = Future<Item=T, Error=io::Error>; | ||
|
|
||
| #[derive(Clone)] |
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.
In the long run we probably don't want impl Clone for TcpListener I think, it seems like it could get into some uncomfortably weird situations if you can silently clone an I/O object. (the actual impl details here look good to me though)
|
So, thinking more, I don't think that readiness actually makes sense to expose directly as a I think we should instead consider exposing a first-class readiness abstraction, which supports Note that Right now, the code sort of contains these abstractions, but they're awkwardly built on top of Futures. I'm increasingly feeling like the right thing to do is actually expose a readiness abstraction under Futures -- possibly via a |
|
OK, I pushed an update to this that cleans things up quite a bit. As I was arguing above, I'm moving away from using Given a This all works like a charm, and makes it possible to wrap the base readiness events in custom leaf futures (that expose various buffering strategies, etc). The thing that's missing here is any notion of compositionality at the |
|
I want to explore using TLS to talk to the event loop fairly soon -- that's an essential enough piece, with enough unknowns, that I'd like to get it squared away early. |
|
|
||
| fn _await(&mut self, done: &mut FnMut() -> bool) { | ||
| while !done() { | ||
| pub fn run(&mut self) { |
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.
It may be worth getting cargo test to work in this directory perhaps to see how this hooks up with driving a future
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.
Yep. Had limited time so wanted to get a draft in front of you first, but once you're OK with the general strategy here I'll wrap up the final bits.
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.
Yeah everything's looking good to me, what I expected!
|
Closing this out. Will open a fresh PR with the new version. |
A nice way of working with tasks without allocations.
Here's a first, quick attempt at mio reintegration.
It mostly matches what we discussed, in terms of using global lock-free token allocation, and a hashmap for dispatch.
The interesting new piece is trying to tease out the readiness vs completion story. I introduced a notion of "ReadinessFuture", which is one where basically
pollis meaningless butschedulewaits for readiness. Then there's a completion layer that lets you couple a readiness future with a custom poll which will attempt completion.In principle, this should allow us to expose readiness futures at the lowest levels, and then pair them up with completions to give you various higher-level APIs (without being locked into those).
This should also be useful for things like writing a proxy server, where you might want to join a pair of readiness futures (one for reading from one socket, one for writing to another), and then complete with an action that uses both sockets.
Curious what you think of this factoring!