[][src]Struct desync::desync::Desync

pub struct Desync<T: Send + Unpin> { /* fields omitted */ }

A data storage structure used to govern synchronous and asynchronous access to an underlying object.

Implementations

impl<T: 'static + Send + Unpin> Desync<T>[src]

pub fn new(data: T) -> Desync<T>[src]

Creates a new Desync object

pub fn async<TFn>(&self, job: TFn) where
    TFn: 'static + Send + FnOnce(&mut T), 
[src]

👎 Deprecated since 0.3.0:

please use desync instead

Performs an operation asynchronously on this item. This function will return immediately and the job will happen on a separate thread at some time in the future (generally fairly soon).

Jobs are always performed in the order that they are queued and are always performed synchronously with respect to this object.

pub fn desync<TFn>(&self, job: TFn) where
    TFn: 'static + Send + FnOnce(&mut T), 
[src]

Performs an operation asynchronously on this item. This function will return immediately and the job will happen on a separate thread at some time in the future (generally fairly soon).

Jobs are always performed in the order that they are queued and are always performed synchronously with respect to this object.

pub fn sync<TFn, Result>(&self, job: TFn) -> Result where
    TFn: Send + FnOnce(&mut T) -> Result,
    Result: Send
[src]

Performs an operation synchronously on this item. This will be queued with any other jobs that this item may be performing, and this function will not return until the job is complete and the result is available.

pub fn try_sync<TFn, FnResult>(
    &self,
    job: TFn
) -> Result<FnResult, TrySyncError> where
    TFn: Send + FnOnce(&mut T) -> FnResult,
    FnResult: Send
[src]

Performs an operation synchronously on this item,

pub fn future<TFn, TOutput>(
    &self,
    job: TFn
) -> impl Future<Output = Result<TOutput, Canceled>> + Send where
    TFn: 'static + Send + for<'a> FnOnce(&'a mut T) -> BoxFuture<'a, TOutput>,
    TOutput: 'static + Send
[src]

👎 Deprecated since 0.7.0:

please use either future_desync or future_sync to schedule futures

Deprecated name for future_desync

pub fn future_desync<TFn, TOutput>(&self, job: TFn) -> SchedulerFuture<TOutput>

Notable traits for SchedulerFuture<T>

impl<T: Send> Future for SchedulerFuture<T> type Output = Result<T, Canceled>;
where
    TFn: 'static + Send + for<'a> FnOnce(&'a mut T) -> BoxFuture<'a, TOutput>,
    TOutput: 'static + Send
[src]

Performs an operation asynchronously on the contents of this item, returning the result via a future.

The future will be scheduled in the background, so it will make progress even if the current scheduler is blocked for any reason. Additionally, it's not necessary to await the returned future, which can be discarded if necessary.

The future returned is a BoxFuture, which you can create using .boxed() or Box::pin() on a future. This is solely to work around a limitation in Rust's type system (it's not presently possible to introduce the lifetime from for<'a> into the return type of a function)

pub fn future_sync<'a, TFn, TOutput>(
    &'a self,
    job: TFn
) -> impl 'a + Future<Output = Result<TOutput, Canceled>> + Send where
    TFn: 'a + Send + for<'b> FnOnce(&'b mut T) -> BoxFuture<'b, TOutput>,
    TOutput: 'a + Send
[src]

Performs an operation asynchronously on the contents of this item, returning a future that must be awaited before it is dropped.

The future will be scheduled in the current execution context, so it will only make progress if the current scheduler is running. The task will be cancelled and will not complete execution if the future is dropped before completion, so it's usually necessary to await the result of this function for the task to behave correctly.

The future returned is a BoxFuture, which you can create using .boxed() or Box::pin() on a future. This is solely to work around a limitation in Rust's type system (it's not presently possible to introduce the lifetime from for<'a> into the return type of a function)

pub fn after<'a, TFn, Res: 'static + Send, Fut: 'static + Future + Send>(
    &self,
    after: Fut,
    job: TFn
) -> impl 'static + Future<Output = Result<Res, Canceled>> + Send where
    TFn: 'static + Send + FnOnce(&mut T, Fut::Output) -> Res, 
[src]

After the pending operations for this item are performed, waits for the supplied future to complete and then calls the specified function

Trait Implementations

impl<T: Send + Unpin> Drop for Desync<T>[src]

impl<T: Send + Unpin> Send for Desync<T>[src]

impl<T: Send + Unpin> Sync for Desync<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Desync<T> where
    T: RefUnwindSafe

impl<T> Unpin for Desync<T>

impl<T> UnwindSafe for Desync<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.