From 753336de8e2e31eabfd1d4db867a7529ad38e568 Mon Sep 17 00:00:00 2001 From: Stjepan Glavina Date: Mon, 15 Oct 2018 22:24:00 +0200 Subject: [PATCH] threadpool: Arc instead of Inner in Notifier (#702) --- tokio-threadpool/src/notifier.rs | 8 +++----- tokio-threadpool/src/worker/mod.rs | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/tokio-threadpool/src/notifier.rs b/tokio-threadpool/src/notifier.rs index 74c78cc80..3c4dfa698 100644 --- a/tokio-threadpool/src/notifier.rs +++ b/tokio-threadpool/src/notifier.rs @@ -3,7 +3,7 @@ use task::Task; use std::mem; use std::ops; -use std::sync::{Arc, Weak}; +use std::sync::Arc; use futures::executor::Notify; @@ -13,7 +13,7 @@ use futures::executor::Notify; /// to poll the future again. #[derive(Debug)] pub(crate) struct Notifier { - pub inner: Weak, + pub inner: Arc, } /// A guard that ensures that the inner value gets forgotten. @@ -38,9 +38,7 @@ impl Notify for Notifier { // Bump the ref count let task = task.clone(); - if let Some(inner) = self.inner.upgrade() { - let _ = inner.submit(task, &inner); - } + let _ = self.inner.submit(task, &self.inner); } } } diff --git a/tokio-threadpool/src/worker/mod.rs b/tokio-threadpool/src/worker/mod.rs index 0687b0ac7..438c28d76 100644 --- a/tokio-threadpool/src/worker/mod.rs +++ b/tokio-threadpool/src/worker/mod.rs @@ -222,7 +222,7 @@ impl Worker { // Get the notifier. let notify = Arc::new(Notifier { - inner: Arc::downgrade(&self.inner), + inner: self.inner.clone(), }); let mut first = true;