Remove DropSource from mio

I'm... not sure if it does anything any more as a `ReadinessStream` isn't
clone-able nor is it split. As a result, I don't think we need it.
This commit is contained in:
Alex Crichton 2016-08-02 10:37:32 -07:00
parent 5970203b21
commit 79760da66c
2 changed files with 2 additions and 35 deletions

View File

@ -232,6 +232,7 @@ impl Loop {
fn deschedule(&self, token: usize) {
let mut dispatch = self.dispatch.borrow_mut();
dispatch.get_mut(token).unwrap();
// TODO: was... this supposed to do something?
}
fn consume_queue(&self) {

View File

@ -1,41 +1,10 @@
use std::io;
use std::sync::Arc;
use futures::stream::Stream;
use futures::{Future, Task, Poll};
use futures_io::{Ready, IoFuture};
use event_loop::{IoSource, LoopHandle};
use readiness_stream::drop_source::DropSource;
// TODO: figure out a nicer way to factor this
mod drop_source {
use event_loop::LoopHandle;
pub struct DropSource {
token: usize,
loop_handle: LoopHandle,
}
impl DropSource {
pub fn new(token: usize, loop_handle: LoopHandle) -> DropSource {
DropSource {
token: token,
loop_handle: loop_handle,
}
}
}
// Safe because no public access exposed to LoopHandle; only used in drop
unsafe impl Sync for DropSource {}
impl Drop for DropSource {
fn drop(&mut self) {
self.loop_handle.drop_source(self.token)
}
}
}
/// A concrete implementation of a stream of readiness notifications for I/O
/// objects that originates from an event loop.
@ -54,7 +23,6 @@ pub struct ReadinessStream {
io_token: usize,
loop_handle: LoopHandle,
source: IoSource,
_drop_source: Arc<DropSource>,
}
impl ReadinessStream {
@ -66,12 +34,10 @@ impl ReadinessStream {
pub fn new(loop_handle: LoopHandle, source: IoSource)
-> Box<IoFuture<ReadinessStream>> {
loop_handle.add_source(source.clone()).map(|token| {
let drop_source = Arc::new(DropSource::new(token, loop_handle.clone()));
ReadinessStream {
io_token: token,
source: source,
loop_handle: loop_handle,
_drop_source: drop_source,
}
}).boxed()
}
@ -95,6 +61,6 @@ impl Stream for ReadinessStream {
impl Drop for ReadinessStream {
fn drop(&mut self) {
self.loop_handle.deschedule(self.io_token)
self.loop_handle.drop_source(self.io_token)
}
}