mirror of
https://github.com/deuxfleurs-org/garage.git
synced 2026-08-29 16:37:09 +00:00
Get rid of background::spawn
This commit is contained in:
@@ -2,20 +2,15 @@
|
||||
|
||||
pub mod worker;
|
||||
|
||||
use core::future::Future;
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tokio::sync::{mpsc, watch};
|
||||
|
||||
use crate::error::Error;
|
||||
use worker::WorkerProcessor;
|
||||
pub use worker::{Worker, WorkerState};
|
||||
|
||||
pub(crate) type JobOutput = Result<(), Error>;
|
||||
|
||||
/// Job runner for futures and async functions
|
||||
pub struct BackgroundRunner {
|
||||
send_worker: mpsc::UnboundedSender<Box<dyn Worker>>,
|
||||
@@ -77,14 +72,3 @@ impl BackgroundRunner {
|
||||
.expect("Could not put worker in queue");
|
||||
}
|
||||
}
|
||||
|
||||
pub fn spawn<T>(job: T)
|
||||
where
|
||||
T: Future<Output = JobOutput> + Send + 'static,
|
||||
{
|
||||
tokio::spawn(async move {
|
||||
if let Err(e) = job.await {
|
||||
error!("{}", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user