Add a method to manually deregister an I/O object

Typically this happens automatically as the `E` in `PollEvented<E>` is an owned
reference (e.g. a `TcpStream`) where dropping that will close the resource,
automatically unregistering it from the event loop. In some situations, however,
this isn't always the case, so the deregistering needs to happen manually.
This commit is contained in:
Alex Crichton
2016-11-04 09:12:00 -07:00
parent 4615c3ea78
commit 0a3dc0bb75
2 changed files with 25 additions and 0 deletions
+4
View File
@@ -435,6 +435,10 @@ impl Inner {
Ok((sched.readiness.clone(), entry.insert(sched).index()))
}
fn deregister_source(&mut self, source: &mio::Evented) -> io::Result<()> {
self.io.deregister(source)
}
fn drop_source(&mut self, token: usize) {
debug!("dropping I/O source: {}", token);
self.io_dispatch.remove(token).unwrap();