Trait exec_rs::Invoker[][src]

pub trait Invoker {
    fn pre_invoke(&self) { ... }
fn invoke_with_mode<'f, T: 'f, F: FnOnce() -> T + 'f>(
        &'f self,
        mode: &'f Mode<'f, T>,
        task: F
    ) -> T { ... }
fn invoke<'f, T: 'f, F: FnOnce() -> T + 'f>(&'f self, task: F) -> T { ... }
fn invoke_with_mode_optional<'f, T: 'f, F: FnOnce() -> T + 'f>(
        &'f self,
        mode: Option<&'f Mode<'f, T>>,
        task: F
    ) -> T { ... }
fn do_invoke<'f, T: 'f, F: FnOnce() -> T + 'f>(
        &'f self,
        mode: Option<&'f Mode<'f, T>>,
        task: F
    ) -> T { ... }
fn post_invoke(&self) { ... }
fn invoke_post_invoke_on_panic(&self) -> bool { ... }
fn and_then<I: Invoker>(self, inner: I) -> CombinedInvoker<Self, I>
    where
        Self: Sized
, { ... } }

Trait that may be implemented for types that manage executing a task that do not care about the return type of the task. Implementors may simply override pre_invoke and post_invoke to run code before or / and after invoking a task or override do_invoke to control exactly how a task is invoked, by default this simply calls the task if no mode was supplied or calls crate::invoke if a mode was supplied.

Calling pre_invoke and post_invoke is managed by invoke_with_mode_optional which is the function used by both invoke_with_mode and invoke and internally calls do_invoke. So if implementors override invoke_with_mode_optional they either must manage calling pre_invoke and post_invoke or not use these functions.

Provided methods

fn pre_invoke(&self)[src]

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

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

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.

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

Invoke a task using this invoker without a Mode.

Calls invoke_with_mode_optional with None as Mode, which in turn calls pre_invoke and post_invoke and invokes the task by calling do_invoke.

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

Invoke a task, optionally with a Mode supplied.

Note that this function is used by both invoke_with_mode and invoke and responsible for invoking pre_invoke and post_invoke and delegating invocation of the task to do_invoke.

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

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.

fn post_invoke(&self)[src]

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

fn invoke_post_invoke_on_panic(&self) -> bool[src]

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

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

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.

Loading content...

Implementors

impl Invoker for BaseInvoker[src]

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

impl<O: Invoker, I: Invoker> Invoker for CombinedInvoker<O, I>[src]

Loading content...