Skip to content

Commit

Permalink
remove taskobjext
Browse files Browse the repository at this point in the history
  • Loading branch information
tinaun committed Jun 14, 2018
1 parent 88af39e commit adbe9f9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 60 deletions.
45 changes: 0 additions & 45 deletions futures-core/src/future/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,51 +26,6 @@ pub trait CoreFutureExt: Future {

impl<T: ?Sized> CoreFutureExt for T where T: Future {}

// should be in std
// impl<'a, F: ?Sized + Future + Unpin> Future for &'a mut F {
// type Output = F::Output;

// fn poll(mut self: PinMut<Self>, cx: &mut task::Context) -> Poll<Self::Output> {
// F::poll(PinMut::new(&mut **self), cx)
// }
// }

// impl<'a, F: ?Sized + Future> Future for PinMut<'a, F> {
// type Output = F::Output;

// fn poll(mut self: PinMut<Self>, cx: &mut task::Context) -> Poll<Self::Output> {
// F::poll((*self).reborrow(), cx)
// }
// }

// if_std! {
// use std::boxed::{Box, PinBox};

// impl<'a, F: ?Sized + Future + Unpin> Future for Box<F> {
// type Output = F::Output;

// fn poll(mut self: PinMut<Self>, cx: &mut task::Context) -> Poll<Self::Output> {
// (**self).poll_unpin(cx)
// }
// }

// impl<'a, F: ?Sized + Future> Future for PinBox<F> {
// type Output = F::Output;

// fn poll(mut self: PinMut<Self>, cx: &mut task::Context) -> Poll<Self::Output> {
// self.as_pin_mut().poll(cx)
// }
// }

// impl<'a, F: Future> Future for ::std::panic::AssertUnwindSafe<F> {
// type Output = F::Output;

// fn poll(mut self: PinMut<Self>, cx: &mut task::Context) -> Poll<Self::Output> {
// unsafe { pinned_field!(self, 0).poll(cx) }
// }
// }
// }

/// A convenience for futures that return `Result` values that includes
/// a variety of adapters tailored to such futures.
pub trait TryFuture {
Expand Down
17 changes: 2 additions & 15 deletions futures-core/src/task/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,11 @@ mod atomic_waker;
#[cfg_attr(feature = "nightly", cfg(target_has_atomic = "ptr"))]
pub use self::atomic_waker::AtomicWaker;

pub use core::task::{TaskObj, UnsafePoll};
pub use core::task::{TaskObj, UnsafeTask};

if_std! {
use std::boxed::PinBox;

/// Extension trait for `TaskObj`, adding methods that require allocation.
pub trait TaskObjExt {
/// Create a new `TaskObj` by boxing the given future.
fn new<F: Future<Output = ()> + Send + 'static>(f: F) -> TaskObj;
}

impl TaskObjExt for TaskObj {
/// Create a new `TaskObj` by boxing the given future.
fn new<F: Future<Output = ()> + Send + 'static>(f: F) -> TaskObj {
TaskObj::from_poll_task(PinBox::new(f))
}
}

/// Extension trait for `Context`, adding methods that require allocation.
pub trait ContextExt {
/// Spawn a future onto the default executor.
Expand All @@ -47,7 +34,7 @@ if_std! {
impl<'a> ContextExt for Context<'a> {
fn spawn<F>(&mut self, f: F) where F: Future<Output = ()> + 'static + Send {
self.executor()
.spawn_obj(TaskObj::new(f)).unwrap()
.spawn_obj(TaskObj::new(PinBox::new(f))).unwrap()
}
}
}

0 comments on commit adbe9f9

Please sign in to comment.