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

Add smol and async_global_executor runtime -- question "how to" in almost prepared PR #3787

Closed
martin-kolarik opened this issue Mar 16, 2025 · 2 comments
Labels
enhancement New feature or request

Comments

@martin-kolarik
Copy link

I have found these related issues/pull requests

I would like to have these in sqlx: 1) smol as a replacement for async_std, and 2) async_global_executor as a less bulky approach. Both use the same internals.

The reason for having both is that both create own static executor, which would end in creating extra thread pool for users using async_global_executor, if sqlx supported smol only.

Description

I have implemented this addition in my fork, but I stopped at forbid(unsafe_code)], because the code requires unsafe:

fn try_read(&mut self, buf: &mut dyn ReadBuf) -> io::Result<usize> {
    unsafe { self.get_mut().read(buf.init_mut()) }
}

It is explained at Async.

Also, I started with fork a month ago, but yesterday async_std become discontiued (https://crates.io/crates/async-std), what added a motivation.

Prefered solution

I think the best solution would be to extract sqlx_rt to separate crate that would allow unsafe for smol and async_global_executor. But, I would like to discuss it first with sqlx owners.

Is this a breaking change? Why or why not?

No, only extending the range of executors.

@martin-kolarik martin-kolarik added the enhancement New feature or request label Mar 16, 2025
@abonander
Copy link
Collaborator

You shouldn't need to use .get_mut(). Since Read is implemented for &TcpStream, you can just do .get_ref().read() instead.

@martin-kolarik
Copy link
Author

You shouldn't need to use .get_mut(). Since Read is implemented for &TcpStream, you can just do .get_ref().read() instead.

Indeed, closing. Two PR for smol and async-global-executor will follow.

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

No branches or pull requests

2 participants