Skip to content

Commit

Permalink
Utilize BoxFuture & remove unnecessary unsafe impl Send
Browse files Browse the repository at this point in the history
  • Loading branch information
mindeng committed Aug 22, 2024
1 parent 7ee2955 commit 511b25b
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/token_bucket.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::{
pin::Pin,
sync::{
atomic::{
AtomicUsize,
Expand All @@ -11,7 +10,7 @@ use std::{
time::{Duration, Instant},
};

use futures::Future;
use futures::{future::BoxFuture, Future};

use crate::rt::delay;

Expand Down Expand Up @@ -219,13 +218,11 @@ impl TokenBucketRateLimiter {
}

struct Token<'a> {
fut: Pin<Box<dyn Future<Output = ()>>>,
fut: BoxFuture<'a, ()>,
token_bucket: &'a TokenBucketRateLimiter,
consumed: bool,
}

unsafe impl Send for Token<'_> {}

impl<'a> Token<'a> {
fn new(duration: Duration, token_bucket: &'a TokenBucketRateLimiter) -> Token<'a> {
let fut = delay(duration);
Expand Down

0 comments on commit 511b25b

Please sign in to comment.