Skip to main content

LockedIoUring

Struct LockedIoUring 

Source
pub struct LockedIoUring { /* private fields */ }
Expand description

Un IoUring partagé entre threads derrière un verrou interne (Send + Sync). Le verrou sérialise les accès userspace au SQ/CQ/slab ; le protocole d’ordering userspace↔kernel du Temps 1 reste inchangé dessous.

Avertissement (Principe 5) : le verrou est un point de contention — sous forte charge multi-thread il sérialise tout. À réserver aux cas simples ou peu sollicités ; pour la performance, préférer le thread-per-core (§2, RingPool). Verrou unique d’abord (Principe 7) ; un affinage (soumission/complétion séparées) n’est envisagé qu’après mesure.

Sûreté : Send + Sync par construction — IoUring est Send, donc FutexMutex<IoUring> est Send + Sync :

fn assert_send_sync<T: Send + Sync>() {}
assert_send_sync::<air_sys_syscall::io_uring::LockedIoUring>();

alors qu’un IoUring nu n’est pas Sync (partage refusé par typage) :

fn assert_sync<T: Sync>() {}
assert_sync::<air_sys_syscall::io_uring::IoUring>(); // ERREUR : IoUring: !Sync

Implementations§

Source§

impl LockedIoUring

Source

pub fn new(entries: NonZeroU32) -> Result<Self, Errno>

Raccourci : LockedIoUring::from_builder(IoUringBuilder::new(entries)).

§Errors

Voir IoUringBuilder::build.

Source

pub fn from_builder(builder: IoUringBuilder) -> Result<Self, Errno>

Construit à partir d’un IoUringBuilder (flags, SQPOLL, etc.).

§Errors

Voir IoUringBuilder::build.

Source

pub fn with_lock<R>(&self, f: impl FnOnce(&mut IoUring) -> R) -> R

Exécute f sur le ring sous-jacent sous le verrou (accès exclusif sérialisé). C’est la primitive complète : toute opération d’IoUring (les ~50 submit_*, les accesseurs de complétion) est accessible ainsi en &self, sans recopier 50 forwarders. Les méthodes nommées ci-dessous en sont de simples raccourcis pour les cas les plus fréquents.

Le verrou est sans empoisonnement ([FutexMutex] n’implémente pas le poisoning) : un panic d’un autre thread sous le verrou ne le rend pas inutilisable (cohérent avec la future synchro sans poisoning d’air-thread).

Source

pub fn submit_read( &self, fd: BorrowedFd<'_>, buffer: Vec<u8>, offset: Option<u64>, ) -> Result<SubmissionToken, Errno>

submit_read (Temps 2a) sous le verrou.

§Errors

Voir IoUring::submit_read.

Source

pub fn submit_write( &self, fd: BorrowedFd<'_>, buffer: Vec<u8>, offset: Option<u64>, ) -> Result<SubmissionToken, Errno>

submit_write (Temps 2a) sous le verrou.

§Errors

Voir IoUring::submit_write.

Source

pub fn submit_nop(&self) -> Result<SubmissionToken, Errno>

submit_nop (Temps 1) sous le verrou.

§Errors

Voir IoUring::submit_nop.

Source

pub fn submit(&self) -> Result<u32, Errno>

submit (Temps 1) sous le verrou.

§Errors

Voir IoUring::submit.

Source

pub fn submit_and_wait(&self, want: u32) -> Result<u32, Errno>

submit_and_wait (Temps 1) sous le verrou.

Attention : l’attente bloque avec le verrou tenu — un seul thread attend à la fois. Pour de l’attente concurrente, préférer le thread-per-core.

§Errors

Voir IoUring::submit_and_wait.

Source

pub fn wait_completion(&self) -> Result<Completion, Errno>

wait_completion (Temps 1) sous le verrou.

§Errors

Voir IoUring::wait_completion.

Source

pub fn try_completion(&self) -> Option<Completion>

try_completion (Temps 1) sous le verrou.

Source

pub fn in_flight(&self) -> u32

Nombre d’opérations en vol (sous le verrou).

Trait Implementations§

Source§

impl Debug for LockedIoUring

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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.