pub struct MergeSubmitter<C: CbArgs, S: BlockingTxTrait<Box<IOEvent<C>>>, B: BorrowMut<MergeBuffer<C>>, F: Fn(C, Errno)> { /* 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.
C: The custom callback args for merged IOEvent
S: The channel sender to submit IOEvent
B: owned MergeBuffer, or reference to MergeBuffer
F: the callback closure to process the merged event C on failure, allow them to capture
customized parameters
Implementations§
Source§impl<C, S, F> MergeSubmitter<C, S, MergeBuffer<C>, F>
impl<C, S, F> MergeSubmitter<C, S, MergeBuffer<C>, F>
Source§impl<C, S, B, F> MergeSubmitter<C, S, B, F>where
C: CbArgs,
S: BlockingTxTrait<Box<IOEvent<C>>>,
B: BorrowMut<MergeBuffer<C>>,
F: Fn(C, Errno),
impl<C, S, B, F> MergeSubmitter<C, S, B, F>where
C: CbArgs,
S: BlockingTxTrait<Box<IOEvent<C>>>,
B: BorrowMut<MergeBuffer<C>>,
F: Fn(C, Errno),
pub fn with_buffer( fd: RawFd, sender: S, action: IOAction, buffer: B, on_failure: F, ) -> Self
Sourcepub fn add_event(&mut self, event: IOEvent<C>) -> Result<(), Errno>
pub fn add_event(&mut self, event: IOEvent<C>) -> Result<(), Errno>
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
event- TheIOEventto add.
§Returns
An Ok(()) on success.
When submit sender closed, set Errno::SHUTDOWN on event and return the same Errno
On debug mode, will validate event.fd and event.action.