Generate jobs rather than writing out each one

This commit is contained in:
asonix 2018-11-07 20:03:39 -06:00
parent 3f6e27a9f7
commit 5b8ec51e33
2 changed files with 16 additions and 76 deletions

View file

@ -50,44 +50,14 @@ fn main() -> Result<(), Error> {
let jobs_actor = builder.build()?;
let jobs = vec![
MyJobArguments {
some_usize: 0,
other_usize: 1,
},
MyJobArguments {
some_usize: 1,
other_usize: 2,
},
MyJobArguments {
some_usize: 3,
other_usize: 5,
},
MyJobArguments {
some_usize: 8,
other_usize: 13,
},
MyJobArguments {
some_usize: 21,
other_usize: 34,
},
MyJobArguments {
some_usize: 55,
other_usize: 89,
},
MyJobArguments {
some_usize: 144,
other_usize: 233,
},
MyJobArguments {
some_usize: 377,
other_usize: 610,
},
MyJobArguments {
some_usize: 987,
other_usize: 1597,
},
];
let (_, _, jobs) = (1..18).fold((0, 1, Vec::new()), |(x, y, mut acc), _| {
acc.push(MyJobArguments {
some_usize: x,
other_usize: y,
});
(y, x + y, acc)
});
for job in jobs {
jobs_actor.do_send(QueueJob(MyProcessor::new_job(job, None, None)?));

View file

@ -53,44 +53,14 @@ fn main() {
let handle = runner.spawn();
let jobs = vec![
MyJobArguments {
some_usize: 0,
other_usize: 1,
},
MyJobArguments {
some_usize: 1,
other_usize: 2,
},
MyJobArguments {
some_usize: 3,
other_usize: 5,
},
MyJobArguments {
some_usize: 8,
other_usize: 13,
},
MyJobArguments {
some_usize: 21,
other_usize: 34,
},
MyJobArguments {
some_usize: 55,
other_usize: 89,
},
MyJobArguments {
some_usize: 144,
other_usize: 233,
},
MyJobArguments {
some_usize: 377,
other_usize: 610,
},
MyJobArguments {
some_usize: 987,
other_usize: 1597,
},
];
let (_, _, jobs) = (1..18).fold((0, 1, Vec::new()), |(x, y, mut acc), _| {
acc.push(MyJobArguments {
some_usize: x,
other_usize: y,
});
(y, x + y, acc)
});
for job in jobs {
tokio::spawn(