WorkerTaskContext: make it Send + Sync

This commit is contained in:
Dietmar Maurer 2021-09-27 08:39:44 +02:00
parent 6d5d305d9d
commit b446fa14c5
2 changed files with 3 additions and 3 deletions

View File

@ -3,7 +3,7 @@ use anyhow::{bail, Error};
/// Worker task abstraction /// Worker task abstraction
/// ///
/// A worker task is a long running task, which usually logs output into a separate file. /// A worker task is a long running task, which usually logs output into a separate file.
pub trait WorkerTaskContext { pub trait WorkerTaskContext: Send + Sync {
/// Test if there was a request to abort the task. /// Test if there was a request to abort the task.
fn abort_requested(&self) -> bool; fn abort_requested(&self) -> bool;

View File

@ -19,7 +19,7 @@ use crate::tools::ParallelHandler;
/// A VerifyWorker encapsulates a task worker, datastore and information about which chunks have /// A VerifyWorker encapsulates a task worker, datastore and information about which chunks have
/// already been verified or detected as corrupt. /// already been verified or detected as corrupt.
pub struct VerifyWorker { pub struct VerifyWorker {
worker: Arc<dyn WorkerTaskContext + Send + Sync>, worker: Arc<dyn WorkerTaskContext>,
datastore: Arc<DataStore>, datastore: Arc<DataStore>,
verified_chunks: Arc<Mutex<HashSet<[u8; 32]>>>, verified_chunks: Arc<Mutex<HashSet<[u8; 32]>>>,
corrupt_chunks: Arc<Mutex<HashSet<[u8; 32]>>>, corrupt_chunks: Arc<Mutex<HashSet<[u8; 32]>>>,
@ -27,7 +27,7 @@ pub struct VerifyWorker {
impl VerifyWorker { impl VerifyWorker {
/// Creates a new VerifyWorker for a given task worker and datastore. /// Creates a new VerifyWorker for a given task worker and datastore.
pub fn new(worker: Arc<dyn WorkerTaskContext + Send + Sync>, datastore: Arc<DataStore>) -> Self { pub fn new(worker: Arc<dyn WorkerTaskContext>, datastore: Arc<DataStore>) -> Self {
Self { Self {
worker, worker,
datastore, datastore,