Struct leaky_bucket::AcquireOwned
source · pub struct AcquireOwned { /* private fields */ }
Expand description
The future associated with acquiring permits from a rate limiter using
RateLimiter::acquire_owned
.
Implementations§
source§impl AcquireOwned
impl AcquireOwned
sourcepub fn is_core(&self) -> bool
pub fn is_core(&self) -> bool
Test if this acquire task is currently coordinating the rate limiter.
§Examples
use leaky_bucket::RateLimiter;
use std::future::Future;
use std::sync::Arc;
use std::task::Context;
struct Waker;
let limiter = Arc::new(RateLimiter::builder().build());
let waker = Arc::new(Waker).into();
let mut cx = Context::from_waker(&waker);
let a1 = limiter.acquire_owned(1);
tokio::pin!(a1);
assert!(!a1.is_core());
assert!(a1.as_mut().poll(&mut cx).is_pending());
assert!(a1.is_core());
a1.as_mut().await;
// After completion this is no longer a core.
assert!(!a1.is_core());
Trait Implementations§
source§impl Future for AcquireOwned
impl Future for AcquireOwned
Auto Trait Implementations§
impl !Freeze for AcquireOwned
impl !RefUnwindSafe for AcquireOwned
impl Send for AcquireOwned
impl Sync for AcquireOwned
impl !UnwindSafe for AcquireOwned
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<F> IntoFuture for Fwhere
F: Future,
impl<F> IntoFuture for Fwhere
F: Future,
§type IntoFuture = F
type IntoFuture = F
Which kind of future are we turning this into?
source§fn into_future(self) -> <F as IntoFuture>::IntoFuture
fn into_future(self) -> <F as IntoFuture>::IntoFuture
Creates a future from a value. Read more