mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-09-08 00:00:13 +02:00
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:
@@ -232,6 +232,7 @@ impl Loop {
|
|||||||
fn deschedule(&self, token: usize) {
|
fn deschedule(&self, token: usize) {
|
||||||
let mut dispatch = self.dispatch.borrow_mut();
|
let mut dispatch = self.dispatch.borrow_mut();
|
||||||
dispatch.get_mut(token).unwrap();
|
dispatch.get_mut(token).unwrap();
|
||||||
|
// TODO: was... this supposed to do something?
|
||||||
}
|
}
|
||||||
|
|
||||||
fn consume_queue(&self) {
|
fn consume_queue(&self) {
|
||||||
|
|||||||
+1
-35
@@ -1,41 +1,10 @@
|
|||||||
use std::io;
|
use std::io;
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
use futures::stream::Stream;
|
use futures::stream::Stream;
|
||||||
use futures::{Future, Task, Poll};
|
use futures::{Future, Task, Poll};
|
||||||
use futures_io::{Ready, IoFuture};
|
use futures_io::{Ready, IoFuture};
|
||||||
|
|
||||||
use event_loop::{IoSource, LoopHandle};
|
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
|
/// A concrete implementation of a stream of readiness notifications for I/O
|
||||||
/// objects that originates from an event loop.
|
/// objects that originates from an event loop.
|
||||||
@@ -54,7 +23,6 @@ pub struct ReadinessStream {
|
|||||||
io_token: usize,
|
io_token: usize,
|
||||||
loop_handle: LoopHandle,
|
loop_handle: LoopHandle,
|
||||||
source: IoSource,
|
source: IoSource,
|
||||||
_drop_source: Arc<DropSource>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ReadinessStream {
|
impl ReadinessStream {
|
||||||
@@ -66,12 +34,10 @@ impl ReadinessStream {
|
|||||||
pub fn new(loop_handle: LoopHandle, source: IoSource)
|
pub fn new(loop_handle: LoopHandle, source: IoSource)
|
||||||
-> Box<IoFuture<ReadinessStream>> {
|
-> Box<IoFuture<ReadinessStream>> {
|
||||||
loop_handle.add_source(source.clone()).map(|token| {
|
loop_handle.add_source(source.clone()).map(|token| {
|
||||||
let drop_source = Arc::new(DropSource::new(token, loop_handle.clone()));
|
|
||||||
ReadinessStream {
|
ReadinessStream {
|
||||||
io_token: token,
|
io_token: token,
|
||||||
source: source,
|
source: source,
|
||||||
loop_handle: loop_handle,
|
loop_handle: loop_handle,
|
||||||
_drop_source: drop_source,
|
|
||||||
}
|
}
|
||||||
}).boxed()
|
}).boxed()
|
||||||
}
|
}
|
||||||
@@ -95,6 +61,6 @@ impl Stream for ReadinessStream {
|
|||||||
|
|
||||||
impl Drop for ReadinessStream {
|
impl Drop for ReadinessStream {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
self.loop_handle.deschedule(self.io_token)
|
self.loop_handle.drop_source(self.io_token)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user