SQ, CQ and Registrar contain NonNull<io_uring> which point to the same value.
|
pub struct SubmissionQueue<'ring> { |
|
ring: NonNull<uring_sys::io_uring>, |
|
_marker: PhantomData<&'ring mut IoUring>, |
|
} |
|
pub struct CompletionQueue<'ring> { |
|
pub(crate) ring: NonNull<uring_sys::io_uring>, |
|
_marker: PhantomData<&'ring mut IoUring>, |
|
} |
|
pub struct Registrar<'ring> { |
|
ring: NonNull<uring_sys::io_uring>, |
|
_marker: PhantomData<&'ring mut IoUring>, |
|
} |
NonNull::as_ref and NonNull::as_mut require borrow check.
But if we split (SQ, CQ) into a producer thread and a consumer thread, both of them can access the same value without synchronization and break the borrow rule.
SQ, CQ and Registrar contain
NonNull<io_uring>which point to the same value.iou/src/submission_queue.rs
Lines 47 to 50 in 045f8d4
iou/src/completion_queue.rs
Lines 14 to 17 in 045f8d4
iou/src/registrar/mod.rs
Lines 47 to 50 in 045f8d4
NonNull::as_refandNonNull::as_mutrequire borrow check.But if we split (SQ, CQ) into a producer thread and a consumer thread, both of them can access the same value without synchronization and break the borrow rule.