Skip to main content

MergeSubmitter

Struct MergeSubmitter 

Source
pub struct MergeSubmitter<C: IOCallback, S: BlockingTxTrait<Box<IOEvent<C>>>> { /* private fields */ }
Expand description

Manages the submission of IO events, attempting to merge sequential events before sending them to the IO driver.

This component buffers incoming IOEvents into a MergeBuffer. It ensures that events for the same file descriptor and IO action are considered for merging to optimize system calls.

Implementations§

Source§

impl<C: IOCallback, S: BlockingTxTrait<Box<IOEvent<C>>>> MergeSubmitter<C, S>

Source

pub fn new( fd: RawFd, sender: S, merge_size_limit: usize, action: IOAction, ) -> Self

Creates a new MergeSubmitter.

§Arguments
  • fd - The raw file descriptor for IO operations.
  • sender - A channel sender to send prepared IOEvents to the IO driver.
  • merge_size_limit - The maximum data size for a merged event buffer.
  • action - The primary IO action (Read/Write) for this submitter.
Source

pub fn add_event(&mut self, event: IOEvent<C>) -> Result<(), Error>

Adds an IOEvent to the internal buffer, potentially triggering a flush.

If the event cannot be merged with current buffered events (e.g., non-contiguous, exceeding merge limit), the existing buffered events are flushed first. If adding the new event fills the buffer to its merge_size_limit, a flush is also triggered.

§Arguments
§Returns

An Ok(()) on success, or an io::Error if flushing fails. On debug mode, will validate event.fd and event.action.

Source

pub fn flush(&mut self) -> Result<(), Error>

Explicitly flushes any pending buffered events to the IO driver.

§Returns

An Ok(()) on success, or an io::Error if sending the flushed event fails.

Auto Trait Implementations§

§

impl<C, S> Freeze for MergeSubmitter<C, S>
where S: Freeze,

§

impl<C, S> RefUnwindSafe for MergeSubmitter<C, S>

§

impl<C, S> Send for MergeSubmitter<C, S>

§

impl<C, S> Sync for MergeSubmitter<C, S>
where S: Sync, C: Sync,

§

impl<C, S> Unpin for MergeSubmitter<C, S>
where S: Unpin,

§

impl<C, S> UnsafeUnpin for MergeSubmitter<C, S>
where S: UnsafeUnpin,

§

impl<C, S> UnwindSafe for MergeSubmitter<C, S>
where S: UnwindSafe, C: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.