reverse out-of-scope change

This commit is contained in:
wireless4024 2023-02-12 11:18:50 +07:00
parent 20c66f89ad
commit 6a1d254931
No known key found for this signature in database
GPG Key ID: D102C2A868192A39
2 changed files with 7 additions and 20 deletions

View File

@ -10,20 +10,14 @@ async fn handle(_req: Request<Body>) -> Result<Response<Body>, Infallible> {
}
fn main() {
#[cfg(not(feature = "io-uring"))]
let rt = actix_rt::System::with_tokio_rt(|| {
actix_rt::System::with_tokio_rt(|| {
tokio::runtime::Builder::new_multi_thread()
.enable_all()
.build()
.unwrap()
});
#[cfg(feature = "io-uring")]
let rt = actix_rt::System::with_tokio_rt(|| {
tokio_uring::Runtime::new(&tokio_uring::builder())
.unwrap()
});
rt.block_on(async {
// for io_uring feature use `tokio_uring::Runtime::new(&tokio_uring::builder()).unwrap()`
})
.block_on(async {
let make_service =
make_service_fn(|_conn| async { Ok::<_, Infallible>(service_fn(handle)) });

View File

@ -4,22 +4,15 @@
use actix_rt::System;
fn main() {
#[cfg(not(feature = "io-uring"))]
let system = System::with_tokio_rt(|| {
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()
});
#[cfg(feature = "io-uring")]
let system = System::with_tokio_rt(|| {
// build system with tokio uring runtime.
tokio_uring::Runtime::new(&tokio_uring::builder())
.unwrap()
});
system.block_on(async_main());
})
.block_on(async_main());
}
// async main function that acts like #[actix_web::main] or #[tokio::main]