Check for new jobs when a job has been returned

This commit is contained in:
asonix 2018-11-06 21:44:24 -06:00
parent f92ae865a3
commit a142eb2d3f

View file

@ -127,12 +127,22 @@ fn process_jobs(
.fold(
(processors, num_processors),
move |(processors, processor_count), msg| match msg {
ProcessorMessage::Job(job) => Either::A(return_job(
storage.clone(),
processor_count,
processors,
job,
)),
ProcessorMessage::Job(job) => {
let tx = tx.clone();
Either::A(
return_job(storage.clone(), processor_count, processors, job).map(
move |values| {
tokio::spawn(
tx.send(ProcessorMessage::Time(tokio::clock::now()))
.map(|_| ())
.map_err(|_| ()),
);
values
},
),
)
}
ProcessorMessage::Time(_) => Either::B(Either::A(try_process_job(
storage.clone(),
processor_count,