mirror of
https://git.asonix.dog/asonix/background-jobs.git
synced 2024-11-21 19:40:59 +00:00
Generate jobs rather than writing out each one
This commit is contained in:
parent
3f6e27a9f7
commit
5b8ec51e33
2 changed files with 16 additions and 76 deletions
|
@ -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)?));
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in a new issue