pub struct Desync<T: Send> { /* private fields */ }
Expand description
A data storage structure used to govern synchronous and asynchronous access to an underlying object.
Implementations
sourceimpl<T: 'static + Send> Desync<T>
impl<T: 'static + Send> Desync<T>
sourcepub fn async<TFn>(&self, job: TFn)where
TFn: 'static + Send + FnOnce(&mut T),
👎Deprecated since 0.3.0: please use desync
instead
pub fn async<TFn>(&self, job: TFn)where
TFn: 'static + Send + FnOnce(&mut T),
desync
insteadPerforms 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.
sourcepub fn desync<TFn>(&self, job: TFn)where
TFn: 'static + Send + FnOnce(&mut T),
pub fn desync<TFn>(&self, job: TFn)where
TFn: 'static + Send + FnOnce(&mut T),
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.
sourcepub fn sync<TFn, Result>(&self, job: TFn) -> Resultwhere
TFn: Send + FnOnce(&mut T) -> Result,
Result: Send,
pub fn sync<TFn, Result>(&self, job: TFn) -> Resultwhere
TFn: Send + FnOnce(&mut T) -> Result,
Result: Send,
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.
sourcepub fn future<TFn, Item: 'static + Send>(
&self,
job: TFn
) -> Box<dyn Future<Item = Item, Error = Canceled>>where
TFn: 'static + Send + FnOnce(&mut T) -> Item,
pub fn future<TFn, Item: 'static + Send>(
&self,
job: TFn
) -> Box<dyn Future<Item = Item, Error = Canceled>>where
TFn: 'static + Send + FnOnce(&mut T) -> Item,
Performs an operation asynchronously on the contents of this item, returning the result via a future.
sourcepub fn after<'a, TFn, Item: 'static + Send, Error: 'static + Send, Res: 'static + Send, Fut: 'a + Future<Item = Item, Error = Error>>(
&self,
after: Fut,
job: TFn
) -> Box<dyn Future<Item = Res, Error = Error> + 'a>where
TFn: 'static + Send + FnOnce(&mut T, Result<Item, Error>) -> Result<Res, Error>,
pub fn after<'a, TFn, Item: 'static + Send, Error: 'static + Send, Res: 'static + Send, Fut: 'a + Future<Item = Item, Error = Error>>(
&self,
after: Fut,
job: TFn
) -> Box<dyn Future<Item = Res, Error = Error> + 'a>where
TFn: 'static + Send + FnOnce(&mut T, Result<Item, Error>) -> Result<Res, Error>,
After the pending operations for this item are performed, waits for the supplied future to complete and then calls the specified function