[−][src]Struct employer::Employer
An interface for spawning worker threads and storing their results
The description
passed to Employer::new
must implement the
JobDescription
trait.
Methods
impl<K, V, D> Employer<K, V, D>
[src]
impl<K, V, S, F> Employer<K, V, (S, F)> where
(S, F): JobDescription<K, Output = V>,
[src]
(S, F): JobDescription<K, Output = V>,
pub fn with_state(state: S, f: F) -> Self
[src]
Create a new Employer
wither the given shared state and job function
impl<K, V, D> Employer<K, V, D>
[src]
pub fn get<'a, Q>(&'a self, input: &Q) -> Job<'a, K, V> where
Q: Hash + Ord,
K: Borrow<Q>,
[src]
Q: Hash + Ord,
K: Borrow<Q>,
Get the job with the given input
pub fn wait_for<'a, Q>(&'a self, input: &Q) -> Option<OutputGuard<'a, K, V>> where
Q: Hash + Ord,
K: Borrow<Q>,
[src]
Q: Hash + Ord,
K: Borrow<Q>,
Block the thread, wait for a job to finish, and get its result
Returns None
if a job with the given input does not exist
pub fn finished<Q>(&self, input: &Q) -> bool where
Q: Hash + Ord,
K: Borrow<Q>,
[src]
Q: Hash + Ord,
K: Borrow<Q>,
Check if the job with the given input has finished
pub fn in_progress_len(&self) -> usize
[src]
Check the number of jobs that are in progress
pub fn finished_len(&self) -> usize
[src]
Check the number of jobs that are in progress
pub fn finished_iter(&self) -> JobIter<K, V>
[src]
Iterate over finished job input/output pairs
pub fn in_progress_inputs(&self) -> impl Iterator<Item = InputGuard<K, V>>
[src]
Iterate over in_progress job inputs
pub fn finished_inputs(&self) -> impl Iterator<Item = InputGuard<K, V>>
[src]
Iterate over finished job inputs
pub fn inputs(&self) -> impl Iterator<Item = InputGuard<K, V>>
[src]
Iterate over all job inputs
pub fn outputs(&self) -> impl Iterator<Item = OutputGuard<K, V>>
[src]
Iterate over finished job outputs
impl<K, V, D> Employer<K, V, D> where
K: Ord + Hash + Clone + Send + Sync + 'static,
V: Send + Sync + 'static,
D: JobDescription<K, Output = V> + 'static,
[src]
K: Ord + Hash + Clone + Send + Sync + 'static,
V: Send + Sync + 'static,
D: JobDescription<K, Output = V> + 'static,
pub fn start(&self, input: K)
[src]
Start a new job with the the given input if one with the same input is not in progress or finished
If you want to start the job even if one with the same input
is already finished, use
Employer::restart
or
Employer::restart_if
.
pub fn restart(&self, input: K)
[src]
Start a new job with the given input if one with the same input is not in progress
If you want to avoid starting a new job if one with the same
input has already finished, use
Employer::start
.
pub fn restart_if<G>(&self, input: K, condition: G) where
G: FnOnce(&V) -> bool,
[src]
G: FnOnce(&V) -> bool,
Start a new job with the given input if one with the same input is not in progress, and if it exists and is finished, the result satisfies the supplied condition
An example use case is if your job involves IO. In this case,
your work function could return a Result
, and the condition
supplied to this function would be Result::is_err
.
If you want to avoid starting a new job if one with the same
input has already finished, use
Employer::start
.
pub fn remove<Q>(&self, input: &Q) where
Q: Hash + Ord,
K: Borrow<Q>,
[src]
Q: Hash + Ord,
K: Borrow<Q>,
Remove a finished job with the given input
Trait Implementations
impl<K, V, D> Debug for Employer<K, V, D>
[src]
impl<K, V, D> Default for Employer<K, V, D> where
D: Default,
[src]
D: Default,
impl<K, V, D> From<D> for Employer<K, V, D>
[src]
impl<K, V, D> From<Employer<K, V, D>> for Arc<D>
[src]
impl<'a, K, V, H> IntoIterator for &'a Employer<K, V, H>
[src]
Auto Trait Implementations
impl<K, V, D> !RefUnwindSafe for Employer<K, V, D>
impl<K, V, D> Send for Employer<K, V, D> where
D: Send + Sync,
K: Send + Sync,
V: Send + Sync,
D: Send + Sync,
K: Send + Sync,
V: Send + Sync,
impl<K, V, D> Sync for Employer<K, V, D> where
D: Send + Sync,
K: Send + Sync,
V: Send + Sync,
D: Send + Sync,
K: Send + Sync,
V: Send + Sync,
impl<K, V, D> Unpin for Employer<K, V, D>
impl<K, V, D> !UnwindSafe for Employer<K, V, D>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<!> for T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,