pub struct AtomicFuture<'a> { /* private fields */ }
Expand description

A lock-free thread-safe future.

Implementations§

source§

impl<'a> AtomicFuture<'a>

source

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

Create a new AtomicFuture.

source

pub unsafe fn new_local<F: Future<Output = R> + 'a, R: 'a>( future: F, detached: bool ) -> Self

Create a new AtomicFuture from a !Send future.

§Safety

The caller must uphold the Send requirements.

source

pub fn try_poll(&self, cx: &mut Context<'_>) -> AttemptPollResult

Attempt to poll the underlying future.

try_poll ensures that the future is polled at least once more unless it has already finished.

source

pub fn mark_ready(&self) -> bool

Marks the future as ready and returns true if it needs to be added to a run queue, i.e. it isn’t already ready, active or done.

source

pub unsafe fn drop_future_unchecked(&self)

Drops the future without checking its current state.

§Safety

This doesn’t check the current state, so this must only be called if it is known that there is no concurrent access. This also does not include any memory barriers before dropping the future.

source

pub fn try_drop(&self) -> Result<(), ()>

Drops the future if it is not currently being polled. Returns success if the future was dropped or was already dropped.

source

pub fn cancel(&self) -> bool

Cancels the task. Returns true if the task needs to be added to a run queue.

source

pub fn detach(&self)

Marks the task as detached.

source

pub fn is_detached_or_cancelled(&self) -> bool

Returns true if the task is detached or cancelled.

source

pub unsafe fn take_result<R>(&self) -> Option<R>

Takes the result.

§Safety

The caller must guarantee that R is the correct type.

Trait Implementations§

source§

impl Drop for AtomicFuture<'_>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl Send for AtomicFuture<'_>

source§

impl Sync for AtomicFuture<'_>

AtomicFuture is safe to access from multiple threads at once.

Auto Trait Implementations§

§

impl<'a> !Freeze for AtomicFuture<'a>

§

impl<'a> !RefUnwindSafe for AtomicFuture<'a>

§

impl<'a> Unpin for AtomicFuture<'a>

§

impl<'a> !UnwindSafe for AtomicFuture<'a>

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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>,

§

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>,

§

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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more