Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unsafe impl Send+Sync for Submitter, SubmissionQueue, CompletionQueue #283

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

problame
Copy link

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 neondatabase@bbc5a0c

…onQueue`

The `IoUring` type already has `Send` + `Sync` impls.

In [tokio-epoll-uring](https://github.com/neondatabase/tokio-epoll-uring),
we use `split()` and need the `Submitter`, `SubmissionQueue` and
`CompletionQueue` to be `Send` (not sync, though).

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

---------

Co-authored-by: Conrad Ludgate <[email protected]>
Cherry picked from commit neondatabase/fork--tokio-rs--io-uring#bbc5a0c5f6cde9051037ec2fcc648cbadb7a80b4
@quininer
Copy link
Member

quininer commented Apr 30, 2024

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

@problame
Copy link
Author

problame commented May 3, 2024

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().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants