-
Notifications
You must be signed in to change notification settings - Fork 341
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
Expose net::driver::Watcher mechanism #293
Comments
This API still requires some work, but just to set expectations: it's unlikely we'll expose On top of that we should also provide a way to access the |
I think this is really important. Just got blocked trying to set the ecn bits on a udp datagram. Most async system programs need this in some form. |
@dvc94ch What if we had an API along these lines? Would that work for you? enum Interest {
Read,
Write,
Both,
}
// Registers an I/O handle so that the current task gets woken up when it becomes ready.
fn register(cx: &mut Context<'_>, fd: impl AsRawFd, interest: Interest);
// Unregisters an I/O handle.
fn unregister(fd: impl AsRawFd); |
So how would this be used exactly? Are these operations idempotent? But it seems reasonable. fn poll_send(&self, cx: &mut Context, data: &[u8]) -> Poll<Result<()>> {
match self.socket.try_send(data) {
Ok(res) => {
unregister(cx);
Poll::Ready(Ok(res))
}
Err(ref e) if e.kind() == ErrorKind::WouldBlock => {
register(cx, self.socket.as_raw_fd(), Interest::Write);
Poll::Pending
}
Err(e) => {
unregister(cx);
Poll::Ready(Err(e))
}
}
} |
@dvc94ch Almost -- this is closer to what I had in mind: impl MyIoHandle {
fn poll_send(&self, cx: &mut Context, data: &[u8]) -> Poll<Result<()>> {
let mut registered = false;
loop {
match self.socket.try_send(data) {
Ok(res) => return Poll::Ready(Ok(res)),
Err(ref e) if e.kind() == ErrorKind::WouldBlock => {
if registered {
return Poll::Pending;
} else {
register(cx, &self.socket, Interest::Write);
registered = true;
}
}
Err(e) => return Poll::Ready(Err(e)),
}
}
}
}
impl Drop for MyIoHandle {
fn drop(&mut self) {
unregister(&self.socket);
}
} |
This blocks quinn-rs/quinn#502, which needs ECN support. |
I need to call What I'm missing is a public API equivalent of |
Hello, I somehow got stuck on the same issue like this. Is it going to introduce new interface in #626, or |
I implement async serial port interface (like tokio-serial) which needs |
@katyo Such a flag can easily be considered standard and lead to de-facto standardisation. |
@skade maybe some features need some experience to get right (otherwise you'd have done it by now)? If you want to be pendantic you could impl api v1 in terms of v2 under a compat flag and have a long deprecation period. If you start with something, and let people try it, you might come up with something better? |
@dvc94ch I'm definitely sympathetic to do that, but the current proposal is essentially "expose the internals raw", which is definitely not acceptable under the current implementation strategy. |
I think we should expose some internals in any case. Particularly, tokio exposes |
There are discussions about removing PollEvented from tokio 0.3 fwiw, for this very reason |
Re-exporting |
I think if we can have a light wrapper around it, we should be able to expose sth easier with this, yes |
I wonder if we actually need to reexport anything, using |
@dignifiedquire I agree; we probably don't need to -- though I'd still love to find a way to expose the initialized |
Is |
I think smol I'm trying to write a zero-copy between two However I'm thinking: if the writing data from pipe to TCP, and TCP buffer is full, it will return |
I believe this can be closed now because we have You can use |
Crates implementing
Evented
should be able to register a reactor.Follow up from discussion #65
The text was updated successfully, but these errors were encountered: