Struct a10::Config

source ·
pub struct Config<'r> { /* private fields */ }
Expand description

Configuration of a Ring.

Created by calling Ring::config.

Implementations§

source§

impl<'r> Config<'r>

source

pub const fn disable(self) -> Config<'r>

Start the ring in a disabled state.

While the ring is disabled submissions are not allowed. To enable the ring use Ring::enable.

source

pub const fn single_issuer(self) -> Config<'r>

Enable single issuer.

This hints to the kernel that only a single thread will submit requests, which is used for optimisations within the kernel. This means that only the thread that build the ring or enabled it (after starting in disable mode) may register resources with the ring, resources such as the ReadBufPool.

This optimisation is enforces by the kernel, which will return EEXIST or AlreadyExists if another thread attempt to register resource or otherwise use the Ring in a way that is not allowed.

source

pub const fn defer_task_run(self) -> Config<'r>

Defer task running.

By default, kernel will process all outstanding work at the end of any system call or thread interrupt. This can delay the application from making other progress.

Enabling this option will hint to kernel that it should defer work until Ring::poll is called. This way the work is done in the Ring::poll.

This options required Config::single_issuer to be set. This option does not work with Config::with_kernel_thread set.

source

pub const fn with_completion_queue_size(self, entries: u32) -> Self

Set the size of the completion queue.

By default the kernel will use a completion queue twice as large as the submission queue (entries in the call to Ring::config).

Uses IORING_SETUP_CQSIZE, added in Linux kernel 5.5.

source

pub const fn clamp_queue_sizes(self) -> Self

Clamp queue sizes to the maximum.

The maximum queue sizes aren’t exposed by the kernel, making this the only way (currently) to get the largest possible queues.

Uses IORING_SETUP_CLAMP, added in Linux kernel 5.6.

source

pub const fn with_kernel_thread(self, enabled: bool) -> Self

Start a kernel thread polling the Ring.

When this option is enabled a kernel thread is created to perform submission queue polling. This allows issuing I/O without ever context switching into the kernel.

§Notes

When setting this to false it significantly changes the way A10 works. With this disabled you need to call Ring::poll to submit I/O work, with this enables this is done by the kernel thread. That means that if multiple threads use the same SubmissionQueue their submissions might not actually be submitted until Ring::poll is called.

source

pub const fn with_cpu_affinity(self, cpu: u32) -> Self

Set the CPU affinity of kernel thread polling the Ring.

Only works in combination with Config::with_kernel_thread.

source

pub const fn with_idle_timeout(self, timeout: Duration) -> Self

Set the idle timeout of the kernel thread polling the submission queue. After timeout time has passed after the last I/O submission the kernel thread will go to sleep. If the I/O is kept busy the kernel thread will never sleep. Note that A10 will ensure the kernel thread is woken up when more submissions are added.

The accuracy of timeout is only in milliseconds, anything more precise will be discarded.

source

pub const fn attach(self, other_ring: &'r Ring) -> Self

Attach the new (to be created) ring to other_ring.

This will cause the Ring being created to share the asynchronous worker thread backend of the specified other_ring, rather than create a new separate thread pool.

Uses IORING_SETUP_ATTACH_WQ, added in Linux kernel 5.6.

source

pub const fn attach_queue(self, other_ring: &'r SubmissionQueue) -> Self

Same as Config::attach, but accepts a SubmissionQueue.

source

pub fn build(self) -> Result<Ring>

Build a new Ring.

Trait Implementations§

source§

impl<'r> Clone for Config<'r>

source§

fn clone(&self) -> Config<'r>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'r> Debug for Config<'r>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'r> Freeze for Config<'r>

§

impl<'r> RefUnwindSafe for Config<'r>

§

impl<'r> Send for Config<'r>

§

impl<'r> Sync for Config<'r>

§

impl<'r> Unpin for Config<'r>

§

impl<'r> UnwindSafe for Config<'r>

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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>,

§

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.