Struct MutexSyncExecutor

Source
pub struct MutexSyncExecutor<K, M>
where K: 'static + Sync + Send + Clone + Hash + Ord, M: Borrow<MutexSync<K>> + 'static,
{ /* private fields */ }
Expand description

Struct that implements the ModeWrapper and Invoker traits for any type that borrows MutexSync and a specific key. Enables using MutexSync as a ModeWrapper or Invoker.

Trait Implementations§

Source§

impl<K, M> Invoker for MutexSyncExecutor<K, M>
where K: 'static + Sync + Send + Clone + Hash + Ord, M: Borrow<MutexSync<K>> + 'static,

Source§

fn do_invoke<'f, T: 'f, F: FnOnce() -> T + 'f>( &'f self, mode: Option<&'f Mode<'f, T>>, task: F, ) -> T

Core function responsible for actually invoking the task. This allows implementors to easily override how tasks are invoked without having to worry about doing any administrative tasks such as calling pre_invoke and post_invoke as would be the case when overriding invoke_with_mode_optional.
Source§

fn pre_invoke(&self)

Called by invoke_with_mode_optional before invoking each task. Can be used to run code before a task is invoked.
Source§

fn invoke_with_mode<'f, T: 'f, F: FnOnce() -> T + 'f>( &'f self, mode: &'f Mode<'f, T>, task: F, ) -> T

Invoke a task with a Mode. The default implementation for do_invoke delegates to crate::invoke if a mode was supplied. The Mode is applied to the task invoked by this Invoker, meaning the task of modes will run inside the do_invoke invocation so that logic run by the invoker before the task runs executes before the modes and logic run by the invoker after the task executes after the modes.
Source§

fn invoke<'f, T: 'f, F: FnOnce() -> T + 'f>(&'f self, task: F) -> T

Invoke a task using this invoker without a Mode. Read more
Source§

fn invoke_with_mode_optional<'f, T: 'f, F: FnOnce() -> T + 'f>( &'f self, mode: Option<&'f Mode<'f, T>>, task: F, ) -> T

Invoke a task, optionally with a Mode supplied. Read more
Source§

fn post_invoke(&self)

Called by invoke_with_mode_optional after invoking each task. Can be used to run code after a task is invoked.
Source§

fn invoke_post_invoke_on_panic(&self) -> bool

Return true if post_invoke should be called even if the task panicked using a Sentinel, defaults to false.
Source§

fn and_then<I: Invoker>(self, inner: I) -> CombinedInvoker<Self, I>
where Self: Sized,

Combines this Invoker with another Invoker by creating a CombinedInvoker that invokes tasks by first calling this Invoker with a task that submits the supplied task to the other Invoker, meaning the other Invoker will run inside this Invoker in such a way that the logic of this Invoker that runs before the task executes before the logic of the other Invoker but the logic of this Invoker that runs after the task executes after the logic of the other Invoker.
Source§

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,

Source§

fn wrap<'f>( self: Arc<Self>, task: Box<dyn FnOnce() -> T + 'f>, ) -> Box<dyn FnOnce() -> T + 'f>

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

fn into_combiner(self) -> Box<dyn ModeCombiner<'m, T> + Send + Sync + 'm>
where 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.

Auto Trait Implementations§

§

impl<K, M> Freeze for MutexSyncExecutor<K, M>
where K: Freeze, M: Freeze,

§

impl<K, M> RefUnwindSafe for MutexSyncExecutor<K, M>

§

impl<K, M> Send for MutexSyncExecutor<K, M>
where M: Send,

§

impl<K, M> Sync for MutexSyncExecutor<K, M>
where M: Sync,

§

impl<K, M> Unpin for MutexSyncExecutor<K, M>
where K: Unpin, M: Unpin,

§

impl<K, M> UnwindSafe for MutexSyncExecutor<K, M>
where K: UnwindSafe, M: UnwindSafe,

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.

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.