Files
tokio/src/runtime/threadpool/shutdown.rs
T

37 lines
795 B
Rust
Raw Normal View History

use super::Inner;
2018-10-03 03:19:27 +02:00
use tokio_threadpool as threadpool;
2018-03-21 21:23:36 +03:00
use std::fmt;
use futures::{Future, Poll};
/// A future that resolves when the Tokio `Runtime` is shut down.
pub struct Shutdown {
2018-10-03 03:19:27 +02:00
pub(super) inner: threadpool::Shutdown,
2018-03-21 21:23:36 +03:00
}
impl Shutdown {
pub(super) fn shutdown_now(inner: Inner) -> Self {
2018-10-03 03:19:27 +02:00
let inner = inner.pool.shutdown_now();
2018-03-21 21:23:36 +03:00
Shutdown { inner }
}
}
impl Future for Shutdown {
type Item = ();
type Error = ();
fn poll(&mut self) -> Poll<(), ()> {
try_ready!(self.inner.poll());
Ok(().into())
}
}
impl fmt::Debug for Shutdown {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt.debug_struct("Shutdown")
.field("inner", &"Box<Future<Item = (), Error = ()>>")
.finish()
}
}