Skip to main content

setup

Function setup 

Source
pub fn setup<C, Q, W>(
    depth: usize,
    rx: Q,
    cb_workers: W,
    driver_type: Driver,
) -> Result<()>
where C: IOCallback, Q: BlockingRxTrait<Box<IOEvent<C>>> + Send + 'static, W: Worker<C> + Send + 'static,
Expand description

Setup the submission of IO tasks to the underlying driver.

It is generic over the callback type C, the submission queue Q, and the worker type W.

ยงChannel Selection for W (Worker)

When configuring the worker W (usually a channel sender cb_workers), you should choose the crossfire channel type based on your sharing model:

  • Shared Worker (Multiple Producers): If you have multiple submission channels sharing the same callback worker, use the IOWorkers struct, or pass crossfire::MTx (from mpsc or mpmc channels) with your custom worker implementation. This allows multiple producers to send completion events to a single consumer (worker).

  • Single Instance (Dedicated Worker): If you have a single submission channel with its own dedicated callback worker, use crossfire::Tx (from spsc channels). This is more efficient for single-producer scenarios.

  • inline callback: If you have a very light callback logic, you can use Inline