diff options
author | Alex Auvolat <alex@adnab.me> | 2022-06-21 13:50:55 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2022-06-21 13:50:55 +0200 |
commit | 3119ea59b08e62ce14cddeb4809a397785b662bb (patch) | |
tree | 08e54b210ba73988ed1ac56db7045f39f3791bdb /src/util/background/mod.rs | |
parent | e12bc3b5959c0aa5ae3c8a746c62bab2e7343a62 (diff) | |
download | garage-3119ea59b08e62ce14cddeb4809a397785b662bb.tar.gz garage-3119ea59b08e62ce14cddeb4809a397785b662bb.zip |
New worker semantics applied to garage_table
Diffstat (limited to 'src/util/background/mod.rs')
-rw-r--r-- | src/util/background/mod.rs | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/util/background/mod.rs b/src/util/background/mod.rs index 97d25784..c06e2225 100644 --- a/src/util/background/mod.rs +++ b/src/util/background/mod.rs @@ -10,7 +10,8 @@ use std::sync::Arc; use tokio::sync::{mpsc, watch, Mutex}; use crate::error::Error; -use worker::{Worker, WorkerProcessor}; +use worker::WorkerProcessor; +pub use worker::{Worker, WorkerStatus}; pub(crate) type JobOutput = Result<(), Error>; pub(crate) type Job = Pin<Box<dyn Future<Output = JobOutput> + Send>>; @@ -30,9 +31,7 @@ impl BackgroundRunner { let (send_worker, worker_out) = mpsc::unbounded_channel::<Box<dyn Worker>>(); let await_all_done = - tokio::spawn( - async move { WorkerProcessor::new(worker_out, stop_signal).run().await }, - ); + tokio::spawn(async move { WorkerProcessor::new(worker_out, stop_signal).run().await }); let (send_job, queue_out) = mpsc::unbounded_channel(); let queue_out = Arc::new(Mutex::new(queue_out)); @@ -40,11 +39,14 @@ impl BackgroundRunner { for i in 0..n_runners { let queue_out = queue_out.clone(); - send_worker.send(Box::new(job_worker::JobWorker { - index: i, - job_chan: queue_out.clone(), - next_job: None, - })).ok().unwrap(); + send_worker + .send(Box::new(job_worker::JobWorker { + index: i, + job_chan: queue_out.clone(), + next_job: None, + })) + .ok() + .unwrap(); } let bgrunner = Arc::new(Self { |