Struct SpawnableFuture

Source
pub struct SpawnableFuture<'a, O>(/* private fields */);
Expand description

SpawnableFuture is a boxed future that can be spawned without incurring any more allocations i.e. it doesn’t end up with the double boxing that you end up with if you try and spawn Box<dyn Future>. It can be used in place of BoxFuture although it carries more overhead than BoxFuture, so it shouldn’t be used if it isn’t going to be spawned on a scope. SpawnableFuture implements Future but the future will not be running as a separate task if used this way. If polled and then later spawned, the spawned task will be polled again and any waker recorded when polled prior to spawning will be impotent.

Implementations§

Source§

impl<'a, O> SpawnableFuture<'a, O>

Source

pub fn new<F: Future<Output = O> + Send + 'a>(future: F) -> Self
where O: Send + 'a,

Creates a new spawnable future. To spawn the future on a scope, use either spawn_on or compute_on.

Trait Implementations§

Source§

impl<O> Future for &mut SpawnableFuture<'_, O>

Source§

type Output = O

The type of value produced on completion.
Source§

fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>

Attempts to resolve the future to a final value, registering the current task for wakeup if the value is not yet available. Read more
Source§

impl<O> Spawnable for SpawnableFuture<'static, O>

Source§

type Output = O

The type of value produced on completion.
Source§

fn into_task(self, scope: ScopeHandle) -> AtomicFutureHandle<'static>

Converts to a task that can be spawned directly.
Source§

impl<O> Unpin for SpawnableFuture<'_, O>

Auto Trait Implementations§

§

impl<'a, O> Freeze for SpawnableFuture<'a, O>

§

impl<'a, O> !RefUnwindSafe for SpawnableFuture<'a, O>

§

impl<'a, O> Send for SpawnableFuture<'a, O>
where O: Send,

§

impl<'a, O> Sync for SpawnableFuture<'a, O>
where O: Sync,

§

impl<'a, O> !UnwindSafe for SpawnableFuture<'a, O>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.