pub struct IHaveQueue { /* private fields */ }Expand description
Lock-free queue for pending IHave announcements.
Uses crossbeam’s SegQueue for efficient concurrent access without lock contention in the hot path.
Implementations§
Source§impl IHaveQueue
impl IHaveQueue
Sourcepub fn with_flush_threshold(max_size: usize, flush_threshold: usize) -> Self
pub fn with_flush_threshold(max_size: usize, flush_threshold: usize) -> Self
Create a new IHave queue with a specific flush threshold.
Sourcepub fn set_flush_threshold(&self, threshold: usize)
pub fn set_flush_threshold(&self, threshold: usize)
Set the flush threshold (batch size).
Sourcepub fn push(&self, message_id: MessageId, round: u32) -> bool
pub fn push(&self, message_id: MessageId, round: u32) -> bool
Push a new IHave announcement to the queue.
Returns true if the item was queued, false if the queue is full
or not accepting new items.
Sourcepub fn should_flush(&self) -> bool
pub fn should_flush(&self) -> bool
Check if the queue has reached the flush threshold.
This can be used to trigger early batch flush in high-throughput scenarios.
Sourcepub fn flush_threshold(&self) -> usize
pub fn flush_threshold(&self) -> usize
Get the current flush threshold.
Trait Implementations§
Source§impl Debug for IHaveQueue
impl Debug for IHaveQueue
Auto Trait Implementations§
impl !Freeze for IHaveQueue
impl RefUnwindSafe for IHaveQueue
impl Send for IHaveQueue
impl Sync for IHaveQueue
impl Unpin for IHaveQueue
impl UnwindSafe for IHaveQueue
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<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more