Skip to content

Commit 18db42c

Browse files
palanteaufavor
authored andcommitted
Fixes #311 - Make timeouts Sync
Includes-commit: 3faed99 Replicated-from: #312
1 parent 9220e6b commit 18db42c

File tree

4 files changed

+5
-7
lines changed

4 files changed

+5
-7
lines changed

.bleep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
819e3bc852ba912c6fcf02bc9aa4f2c5d6a61d79
1+
a0543ca77c1d82a93f88fdf93f7a0e8e344f03d3

pingora-timeout/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ tokio = { workspace = true, features = [
2424
"sync",
2525
] }
2626
pin-project-lite = "0.2"
27-
futures = "0.3"
2827
once_cell = { workspace = true }
2928
parking_lot = "0.12"
3029
thread_local = "1.0"

pingora-timeout/src/fast_timeout.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ fn check_clock_thread(tm: &Arc<TimerManager>) {
5050
pub struct FastTimeout(Duration);
5151

5252
impl ToTimeout for FastTimeout {
53-
fn timeout(&self) -> BoxFuture<'static, ()> {
53+
fn timeout(&self) -> Pin<Box<dyn Future<Output = ()> + Send + Sync>> {
5454
Box::pin(TIMER_MANAGER.register_timer(self.0).poll())
5555
}
5656

pingora-timeout/src/lib.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ pub mod timer;
3939
pub use fast_timeout::fast_sleep as sleep;
4040
pub use fast_timeout::fast_timeout as timeout;
4141

42-
use futures::future::BoxFuture;
4342
use pin_project_lite::pin_project;
4443
use std::future::Future;
4544
use std::pin::Pin;
@@ -50,7 +49,7 @@ use tokio::time::{sleep as tokio_sleep, Duration};
5049
///
5150
/// Users don't need to interact with this trait
5251
pub trait ToTimeout {
53-
fn timeout(&self) -> BoxFuture<'static, ()>;
52+
fn timeout(&self) -> Pin<Box<dyn Future<Output = ()> + Send + Sync>>;
5453
fn create(d: Duration) -> Self;
5554
}
5655

@@ -60,7 +59,7 @@ pub trait ToTimeout {
6059
pub struct TokioTimeout(Duration);
6160

6261
impl ToTimeout for TokioTimeout {
63-
fn timeout(&self) -> BoxFuture<'static, ()> {
62+
fn timeout(&self) -> Pin<Box<dyn Future<Output = ()> + Send + Sync>> {
6463
Box::pin(tokio_sleep(self.0))
6564
}
6665

@@ -100,7 +99,7 @@ pin_project! {
10099
#[pin]
101100
value: T,
102101
#[pin]
103-
delay: Option<BoxFuture<'static, ()>>,
102+
delay: Option<Pin<Box<dyn Future<Output = ()> + Send + Sync>>>,
104103
callback: F, // callback to create the timer
105104
}
106105
}

0 commit comments

Comments
 (0)