Skip to content

Commit 78d53f7

Browse files
committed
Make SharedHandleContainer a proper struct.
1 parent 2c99b19 commit 78d53f7

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

redis/src/aio/multiplexed_connection.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::{new_shared_handle, ConnectionLike, Runtime, SharedHandleContainer, TaskHandle};
1+
use super::{ConnectionLike, Runtime, SharedHandleContainer, TaskHandle};
22
use crate::aio::{check_resp3, setup_connection};
33
use crate::cmd::Cmd;
44
#[cfg(any(feature = "tokio-comp", feature = "async-std-comp"))]
@@ -517,7 +517,7 @@ impl MultiplexedConnection {
517517
/// This should be called strictly before the multiplexed connection is cloned - that is, before it is returned to the user.
518518
/// Otherwise some clones will be able to kill the backing task, while other clones are still alive.
519519
pub(crate) fn set_task_handle(&mut self, handle: TaskHandle) {
520-
self._task_handle = Some(new_shared_handle(handle));
520+
self._task_handle = Some(SharedHandleContainer::new(handle));
521521
}
522522

523523
/// Sets the time that the multiplexer will wait for responses on operations before failing.

redis/src/aio/pubsub.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::aio::{new_shared_handle, Runtime};
1+
use crate::aio::Runtime;
22
use crate::connection::{
33
check_connection_setup, connection_setup_pipeline, AuthResult, ConnectionSetupComponents,
44
};
@@ -371,7 +371,7 @@ impl PubSub {
371371
let (sender, receiver) = unbounded_channel();
372372
let (sink, driver) = PubSubSink::new(codec, sender);
373373
let handle = Runtime::locate().spawn(driver);
374-
let _task_handle = Some(new_shared_handle(handle));
374+
let _task_handle = Some(SharedHandleContainer::new(handle));
375375
let stream = PubSubStream {
376376
receiver,
377377
_task_handle,

redis/src/aio/runtime.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,15 @@ impl Drop for HandleContainer {
4747
}
4848
}
4949

50-
pub(crate) type SharedHandleContainer = Arc<HandleContainer>;
50+
#[derive(Clone)]
51+
// we allow dead code here because the container isn't used directly, only in the derived drop.
52+
#[allow(dead_code)]
53+
pub(crate) struct SharedHandleContainer(Arc<HandleContainer>);
5154

52-
pub(crate) fn new_shared_handle(handle: TaskHandle) -> SharedHandleContainer {
53-
Arc::new(HandleContainer::new(handle))
55+
impl SharedHandleContainer {
56+
pub(crate) fn new(handle: TaskHandle) -> Self {
57+
Self(Arc::new(HandleContainer::new(handle)))
58+
}
5459
}
5560

5661
impl Runtime {

redis/src/cluster_async/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,7 @@ use std::{
7979
mod request;
8080
mod routing;
8181
use crate::{
82-
aio::{
83-
new_shared_handle, ConnectionLike, MultiplexedConnection, Runtime, SharedHandleContainer,
84-
},
82+
aio::{ConnectionLike, MultiplexedConnection, Runtime, SharedHandleContainer},
8583
cluster::{get_connection_info, slot_cmd},
8684
cluster_client::ClusterParams,
8785
cluster_routing::{
@@ -128,7 +126,7 @@ where
128126
.forward(inner)
129127
.await;
130128
};
131-
let _task_handle = new_shared_handle(Runtime::locate().spawn(stream));
129+
let _task_handle = SharedHandleContainer::new(Runtime::locate().spawn(stream));
132130

133131
ClusterConnection {
134132
sender,

0 commit comments

Comments
 (0)