#[repr(align(64))]pub struct LockFreeRateLimiter { /* private fields */ }Expand description
Ultra-low-latency rate limiter designed for HFT applications Uses lock-free algorithms to eliminate async/await overhead in critical paths
Implementations§
Source§impl LockFreeRateLimiter
impl LockFreeRateLimiter
Sourcepub fn new(max_tokens: NonZeroUsize, window: Duration) -> Self
pub fn new(max_tokens: NonZeroUsize, window: Duration) -> Self
Create a new lock-free rate limiter
Sourcepub fn try_acquire(&self) -> TokenGuard<'_>
pub fn try_acquire(&self) -> TokenGuard<'_>
Try to acquire a token without waiting (lock-free fast path)
Sourcepub fn acquire(&self) -> TokenGuard<'_>
pub fn acquire(&self) -> TokenGuard<'_>
Wait until a token becomes available (may block briefly), returns RAII guard
Sourcepub const fn max_tokens(&self) -> usize
pub const fn max_tokens(&self) -> usize
Get the maximum tokens
Sourcepub fn available_tokens(&self) -> usize
pub fn available_tokens(&self) -> usize
Get the current available tokens
Trait Implementations§
Source§impl Clone for LockFreeRateLimiter
impl Clone for LockFreeRateLimiter
Source§impl Debug for LockFreeRateLimiter
impl Debug for LockFreeRateLimiter
Auto Trait Implementations§
impl !Freeze for LockFreeRateLimiter
impl !RefUnwindSafe for LockFreeRateLimiter
impl Send for LockFreeRateLimiter
impl Sync for LockFreeRateLimiter
impl Unpin for LockFreeRateLimiter
impl UnwindSafe for LockFreeRateLimiter
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