Background task manager #332
1 changed files with 11 additions and 5 deletions
|
@ -494,11 +494,7 @@ impl BlockManager {
|
||||||
fn spawn_background_workers(self: Arc<Self>) {
|
fn spawn_background_workers(self: Arc<Self>) {
|
||||||
// Launch a background workers for background resync loop processing
|
// Launch a background workers for background resync loop processing
|
||||||
let background = self.system.background.clone();
|
let background = self.system.background.clone();
|
||||||
let worker = ResyncWorker {
|
let worker = ResyncWorker::new(self.clone());
|
||||||
manager: self.clone(),
|
|
||||||
tranquilizer: Tranquilizer::new(30),
|
|
||||||
next_delay: Duration::from_secs(10),
|
|
||||||
};
|
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
tokio::time::sleep(Duration::from_secs(10)).await;
|
tokio::time::sleep(Duration::from_secs(10)).await;
|
||||||
background.spawn_worker(worker);
|
background.spawn_worker(worker);
|
||||||
|
@ -744,6 +740,16 @@ struct ResyncWorker {
|
||||||
next_delay: Duration,
|
next_delay: Duration,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ResyncWorker {
|
||||||
|
fn new(manager: Arc<BlockManager>) -> Self {
|
||||||
|
Self {
|
||||||
|
manager,
|
||||||
|
tranquilizer: Tranquilizer::new(30),
|
||||||
|
next_delay: Duration::from_secs(10),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl Worker for ResyncWorker {
|
impl Worker for ResyncWorker {
|
||||||
fn name(&self) -> String {
|
fn name(&self) -> String {
|
||||||
|
|
Loading…
Reference in a new issue