fix test --all-feature failed

This commit is contained in:
wireless4024 2023-02-12 20:58:24 +07:00
parent d700dc2bbb
commit 1e82dad4f0
No known key found for this signature in database
GPG Key ID: D102C2A868192A39
2 changed files with 28 additions and 11 deletions

View File

@ -11,11 +11,18 @@ async fn handle(_req: Request<Body>) -> Result<Response<Body>, Infallible> {
fn main() {
actix_rt::System::with_tokio_rt(|| {
tokio::runtime::Builder::new_multi_thread()
.enable_all()
.build()
.unwrap()
// for io_uring feature use `tokio_uring::Runtime::new(&tokio_uring::builder()).unwrap()`
// this cfg is needed when use it with io-uring, if you don't use io-uring
// you can remove this cfg and last line in this closure
#[cfg(not(feature = "io-uring"))]
{
tokio::runtime::Builder::new_multi_thread()
.enable_all()
.build()
.unwrap()
}
// you can remove this two lines if you don't have tokio_uring feature enabled
#[cfg(feature = "io-uring")]
tokio_uring::Runtime::new(&tokio_uring::builder()).unwrap()
})
.block_on(async {
let make_service =

View File

@ -5,12 +5,22 @@ use actix_rt::System;
fn main() {
System::with_tokio_rt(|| {
// build system with a multi-thread tokio runtime.
tokio::runtime::Builder::new_multi_thread()
.worker_threads(2)
.enable_all()
.build()
.unwrap()
// this cfg is needed when use it with io-uring, if you don't use io-uring
// you can remove this cfg and last line in this closure
#[cfg(not(feature = "io-uring"))]
{
// build system with a multi-thread tokio runtime.
tokio::runtime::Builder::new_multi_thread()
.worker_threads(2)
.enable_all()
.build()
.unwrap()
}
// you can remove this two lines if you don't have tokio_uring feature enabled.
// Note: tokio_uring is single thread and can't be multithreaded,
// unless you spawn multiple of them
#[cfg(feature = "io-uring")]
tokio_uring::Runtime::new(&tokio_uring::builder()).unwrap()
})
.block_on(async_main());
}