threadpool: Arc instead of Inner in Notifier (#702)

This commit is contained in:
Stjepan Glavina 2018-10-15 22:24:00 +02:00 committed by Carl Lerche
parent 65aea16ad1
commit 753336de8e
2 changed files with 4 additions and 6 deletions

View File

@ -3,7 +3,7 @@ use task::Task;
use std::mem; use std::mem;
use std::ops; use std::ops;
use std::sync::{Arc, Weak}; use std::sync::Arc;
use futures::executor::Notify; use futures::executor::Notify;
@ -13,7 +13,7 @@ use futures::executor::Notify;
/// to poll the future again. /// to poll the future again.
#[derive(Debug)] #[derive(Debug)]
pub(crate) struct Notifier { pub(crate) struct Notifier {
pub inner: Weak<Pool>, pub inner: Arc<Pool>,
} }
/// A guard that ensures that the inner value gets forgotten. /// A guard that ensures that the inner value gets forgotten.
@ -38,9 +38,7 @@ impl Notify for Notifier {
// Bump the ref count // Bump the ref count
let task = task.clone(); let task = task.clone();
if let Some(inner) = self.inner.upgrade() { let _ = self.inner.submit(task, &self.inner);
let _ = inner.submit(task, &inner);
}
} }
} }
} }

View File

@ -222,7 +222,7 @@ impl Worker {
// Get the notifier. // Get the notifier.
let notify = Arc::new(Notifier { let notify = Arc::new(Notifier {
inner: Arc::downgrade(&self.inner), inner: self.inner.clone(),
}); });
let mut first = true; let mut first = true;