Introduce a ProcessingTasks constructor

This commit is contained in:
Kerollmops 2022-10-19 11:26:55 +02:00 committed by Clément Renault
parent b373d19831
commit 6e904d0997
No known key found for this signature in database
GPG Key ID: 92ADA4E935E71FA4

View File

@ -128,6 +128,14 @@ struct ProcessingTasks {
} }
impl ProcessingTasks { impl ProcessingTasks {
/// Creates an empty `ProcessingAt` struct.
fn new() -> ProcessingTasks {
ProcessingTasks {
started_at: OffsetDateTime::now_utc(),
processing: RoaringBitmap::new(),
}
}
/// Stores the currently processing tasks, and the date time at which it started. /// Stores the currently processing tasks, and the date time at which it started.
fn start_processing_at(&mut self, started_at: OffsetDateTime, processing: RoaringBitmap) { fn start_processing_at(&mut self, started_at: OffsetDateTime, processing: RoaringBitmap) {
self.started_at = started_at; self.started_at = started_at;
@ -242,16 +250,12 @@ impl IndexScheduler {
options.max_dbs(6); options.max_dbs(6);
let env = options.open(tasks_path)?; let env = options.open(tasks_path)?;
let processing_tasks = ProcessingTasks {
started_at: OffsetDateTime::now_utc(),
processing: RoaringBitmap::new(),
};
let file_store = FileStore::new(&update_file_path)?; let file_store = FileStore::new(&update_file_path)?;
// allow unreachable_code to get rids of the warning in the case of a test build. // allow unreachable_code to get rids of the warning in the case of a test build.
let this = Self { let this = Self {
must_stop_processing: MustStopProcessing::default(), must_stop_processing: MustStopProcessing::default(),
processing_tasks: Arc::new(RwLock::new(processing_tasks)), processing_tasks: Arc::new(RwLock::new(ProcessingTasks::new())),
file_store, file_store,
all_tasks: env.create_database(Some(db_name::ALL_TASKS))?, all_tasks: env.create_database(Some(db_name::ALL_TASKS))?,
status: env.create_database(Some(db_name::STATUS))?, status: env.create_database(Some(db_name::STATUS))?,