diff options
| author | bors <bors@rust-lang.org> | 2018-09-23 10:09:22 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-09-23 10:09:22 +0000 |
| commit | 2287a7a6e293cfcb3bbbdaf3ce2dca5dd2d3184a (patch) | |
| tree | 34343382fd1ed94d646423f0c2106df0ce33d0ab /src/liballoc/boxed.rs | |
| parent | 317ae05a7e4ee5324cc006eda877eb8f2eb57898 (diff) | |
| parent | 1b00f0b9fa92daa489510b8718ce56130420795f (diff) | |
| download | rust-2287a7a6e293cfcb3bbbdaf3ce2dca5dd2d3184a.tar.gz rust-2287a7a6e293cfcb3bbbdaf3ce2dca5dd2d3184a.zip | |
Auto merge of #54339 - cramertj:no-cx, r=aturon
Remove spawning from task::Context r? @aturon cc https://github.com/rust-lang-nursery/wg-net/issues/56
Diffstat (limited to 'src/liballoc/boxed.rs')
| -rw-r--r-- | src/liballoc/boxed.rs | 71 |
1 files changed, 4 insertions, 67 deletions
diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 11b91591593..d4cca387f06 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -60,7 +60,7 @@ use core::borrow; use core::cmp::Ordering; use core::convert::From; use core::fmt; -use core::future::{Future, FutureObj, LocalFutureObj, UnsafeFutureObj}; +use core::future::Future; use core::hash::{Hash, Hasher}; use core::iter::FusedIterator; use core::marker::{Unpin, Unsize}; @@ -68,7 +68,7 @@ use core::mem; use core::pin::Pin; use core::ops::{CoerceUnsized, Deref, DerefMut, Generator, GeneratorState}; use core::ptr::{self, NonNull, Unique}; -use core::task::{Context, Poll, Spawn, SpawnErrorKind, SpawnObjError}; +use core::task::{LocalWaker, Poll}; use raw_vec::RawVec; use str::from_boxed_utf8_unchecked; @@ -804,70 +804,7 @@ impl<T> Generator for Box<T> impl<F: ?Sized + Future + Unpin> Future for Box<F> { type Output = F::Output; - fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> { - F::poll(Pin::new(&mut *self), cx) - } -} - -#[unstable(feature = "futures_api", issue = "50547")] -unsafe impl<'a, T, F> UnsafeFutureObj<'a, T> for Box<F> - where F: Future<Output = T> + 'a -{ - fn into_raw(self) -> *mut () { - Box::into_raw(self) as *mut () - } - - unsafe fn poll(ptr: *mut (), cx: &mut Context) -> Poll<T> { - let ptr = ptr as *mut F; - let pin: Pin<&mut F> = Pin::new_unchecked(&mut *ptr); - F::poll(pin, cx) - } - - unsafe fn drop(ptr: *mut ()) { - drop(Box::from_raw(ptr as *mut F)) - } -} - -#[unstable(feature = "futures_api", issue = "50547")] -impl<Sp> Spawn for Box<Sp> - where Sp: Spawn + ?Sized -{ - fn spawn_obj( - &mut self, - future: FutureObj<'static, ()>, - ) -> Result<(), SpawnObjError> { - (**self).spawn_obj(future) - } - - fn status(&self) -> Result<(), SpawnErrorKind> { - (**self).status() - } -} - -#[unstable(feature = "futures_api", issue = "50547")] -impl<'a, F: Future<Output = ()> + Send + 'a> From<Box<F>> for FutureObj<'a, ()> { - fn from(boxed: Box<F>) -> Self { - FutureObj::new(boxed) - } -} - -#[unstable(feature = "futures_api", issue = "50547")] -impl<'a, F: Future<Output = ()> + 'a> From<Box<F>> for LocalFutureObj<'a, ()> { - fn from(boxed: Box<F>) -> Self { - LocalFutureObj::new(boxed) - } -} - -#[unstable(feature = "futures_api", issue = "50547")] -impl<'a, F: Future<Output = ()> + Send + 'a> From<Pin<Box<F>>> for FutureObj<'a, ()> { - fn from(boxed: Pin<Box<F>>) -> Self { - FutureObj::new(boxed) - } -} - -#[unstable(feature = "futures_api", issue = "50547")] -impl<'a, F: Future<Output = ()> + 'a> From<Pin<Box<F>>> for LocalFutureObj<'a, ()> { - fn from(boxed: Pin<Box<F>>) -> Self { - LocalFutureObj::new(boxed) + fn poll(mut self: Pin<&mut Self>, lw: &LocalWaker) -> Poll<Self::Output> { + F::poll(Pin::new(&mut *self), lw) } } |
