[−][src]Trait employer::JobDescription
A description of a job
This trait defines work to be done through an
Employer
.
This crate provides two implementations. A stateless one,
and a stateful one.
Stateless Example
JobDescription<I, Output = O>
is emplemented for all
F
where F: Fn(I) -> O + Send + Sync
. This is the basic
stateless implementation.
use employer::*; let employer = Employer::new(|i| i + 1); // No state, just a function employer.start(1); assert_eq!(employer.wait_for(&1).unwrap(), 2);
Stateful Example
JobDescription<I, Output = O>
is emplemented for all
(S, F)
where F: Fn(&S, I) -> O + Send + Sync, S: Send + Sync
.
This is the basic stateful implementation. State is shared
accross threads. The function Employer::with_state
makes this easier to construct.
use employer::*; let employer = Employer::with_state(3, |state: &i32, i| i + *state); // A state and a function employer.start(1); assert_eq!(employer.wait_for(&1).unwrap(), 4);
Associated Types
type Output
The job output type
Required methods
Loading content...Implementations on Foreign Types
impl<'a, F, I, O, S> JobDescription<I> for (S, F) where
F: Fn(&S, I) -> O + Send + Sync,
S: Send + Sync,
[src]
Loading content...
F: Fn(&S, I) -> O + Send + Sync,
S: Send + Sync,