mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-23 02:27:40 +08:00
split the run function in two
This commit is contained in:
parent
a8b18b2c96
commit
9ff0fe952e
@ -201,23 +201,29 @@ impl IndexScheduler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// This worker function must be run in a different thread and must be run only once.
|
/// This worker function must be run in a different thread and must be run only once.
|
||||||
fn run(&self) {
|
fn run(&self) -> ! {
|
||||||
loop {
|
loop {
|
||||||
self.wake_up.wait();
|
self.wake_up.wait();
|
||||||
|
|
||||||
|
self.tick()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Create and execute and store the result of one batch of registered tasks.
|
||||||
|
fn tick(&self) {
|
||||||
let mut wtxn = match self.env.write_txn() {
|
let mut wtxn = match self.env.write_txn() {
|
||||||
Ok(wtxn) => wtxn,
|
Ok(wtxn) => wtxn,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::error!("{}", e);
|
log::error!("{}", e);
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let batch = match self.create_next_batch(&wtxn) {
|
let batch = match self.create_next_batch(&wtxn) {
|
||||||
Ok(Some(batch)) => batch,
|
Ok(Some(batch)) => batch,
|
||||||
Ok(None) => continue,
|
Ok(None) => return,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::error!("{}", e);
|
log::error!("{}", e);
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// 1. store the starting date with the bitmap of processing tasks
|
// 1. store the starting date with the bitmap of processing tasks
|
||||||
@ -238,8 +244,7 @@ impl IndexScheduler {
|
|||||||
Ok(()) => log::info!("A batch of tasks was successfully completed."),
|
Ok(()) => log::info!("A batch of tasks was successfully completed."),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::error!("{}", e);
|
log::error!("{}", e);
|
||||||
continue;
|
return;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user