io-uring icon indicating copy to clipboard operation
io-uring copied to clipboard

unsafe impl `Send+Sync` for `Submitter`, `SubmissionQueue`, `CompletionQueue`

Open problame opened this issue 1 year ago • 4 comments

The IoUring type already has Send + Sync impls.

In tokio-epoll-uring, we use split() and need the Submitter, SubmissionQueue and CompletionQueue to be Send (not sync, though).

This PR adds those unsafe impls, and adds hopefully not too repetitive commentary on why these impls are safe.


Co-authored-by: Conrad Ludgate [email protected] Cherry picked from commit https://github.com/neondatabase/fork--tokio-rs--io-uring/commit/bbc5a0c5f6cde9051037ec2fcc648cbadb7a80b4

problame avatar Apr 30 '24 09:04 problame

You seem to have to use unsafe to get &'static mut or use scope thread to make sense. I would recommend submission_shared and completion_shared.

see https://github.com/tokio-rs/io-uring/pull/100/files#diff-3a884378bde161d43e3099c530c5090847e826cb4501d4f7a803144e6bde14d3

quininer avatar Apr 30 '24 15:04 quininer

Sorry, I'm not following. Who's talking about &'static mut ?

I would recommend submission_shared and completion_shared.

The unsafe impls proposed in this PR allow movement of Submitter, SubmissionQueue, and CompletionQueue, to different threads in consuming code, without any unsafe.

I consider that strictly better than the unsafe fn submission_shared() and unsafe fn completion_shared().

problame avatar May 03 '24 08:05 problame

This would be useful in my project as well

Nehliin avatar Nov 09 '24 09:11 Nehliin