fuchsia_async::atomic_future

Struct AtomicFuture

Source
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 cancel_and_detach(&self) -> CancelAndDetachResult

Marks the task as cancelled and detached (for when the caller isn’t interested in waiting for the cancellation to be finished). Returns true if the task should be added to a run queue.

Source

pub fn is_detached(&self) -> bool

Returns true if the task is detached.

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.

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.