pub struct Runner { /* private fields */ }
Expand description
Runner that will hold all the jobs and will start up the execution and eventually will stop it.
Implementations§
source§impl Runner
impl Runner
sourcepub fn new() -> Self
pub fn new() -> Self
Create new runner
Examples found in repository?
examples/basic.rs (line 16)
15 16 17 18 19 20 21 22 23 24 25 26 27
fn main() {
let mut runner = Runner::new();
println!("Adding ExampleJob to the Runner");
runner = runner.add(Box::new(ExampleJob));
println!("Starting the Runner for 20 seconds");
runner = runner.run();
thread::sleep(Duration::from_millis(20 * 1000));
println!("Stopping the Runner");
runner.stop();
}
sourcepub fn add(self, job: Box<dyn Job>) -> Self
pub fn add(self, job: Box<dyn Job>) -> Self
Add jobs into the runner
panics if you try to push a job onto already started runner
Examples found in repository?
examples/basic.rs (line 19)
15 16 17 18 19 20 21 22 23 24 25 26 27
fn main() {
let mut runner = Runner::new();
println!("Adding ExampleJob to the Runner");
runner = runner.add(Box::new(ExampleJob));
println!("Starting the Runner for 20 seconds");
runner = runner.run();
thread::sleep(Duration::from_millis(20 * 1000));
println!("Stopping the Runner");
runner.stop();
}
sourcepub fn jobs_to_run(&self) -> usize
pub fn jobs_to_run(&self) -> usize
Number of jobs ready to start running
sourcepub fn run(self) -> Self
pub fn run(self) -> Self
Start the loop and job execution
Examples found in repository?
examples/basic.rs (line 22)
15 16 17 18 19 20 21 22 23 24 25 26 27
fn main() {
let mut runner = Runner::new();
println!("Adding ExampleJob to the Runner");
runner = runner.add(Box::new(ExampleJob));
println!("Starting the Runner for 20 seconds");
runner = runner.run();
thread::sleep(Duration::from_millis(20 * 1000));
println!("Stopping the Runner");
runner.stop();
}
sourcepub fn stop(self)
pub fn stop(self)
Stop the spawned runner
Examples found in repository?
examples/basic.rs (line 26)
15 16 17 18 19 20 21 22 23 24 25 26 27
fn main() {
let mut runner = Runner::new();
println!("Adding ExampleJob to the Runner");
runner = runner.add(Box::new(ExampleJob));
println!("Starting the Runner for 20 seconds");
runner = runner.run();
thread::sleep(Duration::from_millis(20 * 1000));
println!("Stopping the Runner");
runner.stop();
}
sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Lets us know if the cron worker is running
sourcepub fn is_working(&self) -> bool
pub fn is_working(&self) -> bool
Lets us know if the worker is in the process of executing a job currently
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Runner
impl Send for Runner
impl Sync for Runner
impl Unpin for Runner
impl !UnwindSafe for Runner
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more