Trait exec_rs::ModeWrapper [−][src]
Trait to implement in order to apply a mode to a task. ModeWrappers are supplied to a Mode
using Mode::with
where they might be combined with other ModeWrappers
using the ModeCombiner
supplied by ModeWrapper::into_combiner
.
Unlike Invokers
, Modes
and ModeWrappers
are generic over the return type
of the tasks they may wrap and thus can directly interact with the return value of the task.
This also means that the lifetime of the Mode is tied to the lifetime of the type they are generic over.
Required methods
fn wrap(
self: Arc<Self>,
task: Box<dyn FnOnce() -> T + 'm>
) -> Box<dyn FnOnce() -> T + 'm>
[src]
self: Arc<Self>,
task: Box<dyn FnOnce() -> T + 'm>
) -> Box<dyn FnOnce() -> T + 'm>
Applies this ModeWrapper to a task by wrapping the supplied boxed function into a new boxed function with the same return type and lifetime, both of which this ModeWrapper is generic over.
Provided methods
fn into_combiner(self) -> Box<dyn ModeCombiner<'m, T> + Send + Sync + 'm> where
Self: Sized + Send + Sync + 'm,
[src]
Self: Sized + Send + Sync + 'm,
Consume this ModeWrapper and produce a ModeCombiner
. This is used by
Mode::with
to be able to combine several ModeWrappers and can
reference back to this ModeWrapper to wrap tasks when applying a Mode to a task. Combining
ModeWrappers is implemented by a separate trait to be able to provide a default implementation
in DelegatingModeCombiner
that combines ModeCombiners
by
setting the current ModeCombiner
as the outer ModeCombiner
of the newly added ModeCombiner
so that the iterator walks the ModeCombiners
in the reverse order of which they were added, meaning
the ModeCombiner
that was added first ends up wrapping the task last, meaning its task will be the
outermost task.
Implementors
impl<T, K, M> ModeWrapper<'static, T> for MutexSyncExecutor<K, M> where
T: 'static,
K: 'static + Sync + Send + Clone + Hash + Ord,
M: Borrow<MutexSync<K>> + 'static,
[src]
T: 'static,
K: 'static + Sync + Send + Clone + Hash + Ord,
M: Borrow<MutexSync<K>> + 'static,