Skip to content

Commit

Permalink
Change strong_count to Weak
Browse files Browse the repository at this point in the history
  • Loading branch information
rdettai committed Sep 17, 2024
1 parent e4f45d1 commit c98bfd6
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.

use std::collections::BTreeMap;
use std::sync::Arc;
use std::sync::{Arc, Weak};
use std::time::Duration;

use anyhow::{bail, Context};
Expand Down Expand Up @@ -61,7 +61,7 @@ impl QueueSharedState {
max_age,
max_count,
pruning_interval,
cleanup_handle.clone(),
Arc::downgrade(&cleanup_handle),
));
Self {
metastore,
Expand All @@ -77,7 +77,7 @@ impl QueueSharedState {
max_age: Option<Duration>,
max_count: Option<u32>,
pruning_interval: Duration,
owner_handle: Arc<()>,
owner_handle: Weak<()>,
) {
if max_count.is_none() && max_age.is_none() {
return;
Expand All @@ -91,7 +91,7 @@ impl QueueSharedState {
let mut interval = tokio::time::interval(pruning_interval);
loop {
interval.tick().await;
if Arc::strong_count(&owner_handle) == 1 {
if owner_handle.upgrade().is_none() {
break;
}
let result: Result<_, _> = metastore
Expand Down

0 comments on commit c98bfd6

Please sign in to comment.