You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am currently utilizing the standard tokio crate to start an asynchronous runtime for my app like so:
let runtime = Builder::new_multi_thread().worker_threads(cfg.settings.worker_threads).thread_name("myapp").enable_all().on_thread_start(|| {info!("thread started");}).on_thread_stop(|| {info!("thread stopped");}).build().unwrap_or_else(|e| {terminate!(1,"unable to initialize runtime: {e}.");});
runtime.block_on(async{// do stuff });
Since tokio-uring needs to inject a driver into the runtime to utilize io_uring, is it possible to support this with tokio or will I just need to replace this with tokio_uring::start(async { ... });?
I ask because after reviewing the builder docs it doesn't appear that we have options like worker_threads, on_thread_start, and on_thread_stop to initialize the tokio_uring runtime with.
Would it be possible to nest the tokio-uring runtime within a standard tokio runtime like so for ad hoc file operations?
runtime.block_on(async{// do stuff// io taskslet(tx, rx) = unbounded_channel();
tokio_uring::start(async{let tx = tx.clone();let file = File::open("hello.txt").await?;let buf = vec![0;4096];let(res, buf) = file.read_at(buf,0).await;let n = res?;
tx.send(buf[..n])?;Ok(())});whileletSome(bytes) = rx.recv().await{// handle recv}// do other stuff});
I'm sure nested async runtimes are against best practice, but I wanted to reach out here and get consensus of how others are integrating tokio-uring into their projects if they depended on the standard tokio builder options. I may be overthinking this or missing something. Any pointers in the right direction would be helpful.
The text was updated successfully, but these errors were encountered:
Hello!
I am currently utilizing the standard
tokio
crate to start an asynchronous runtime for my app like so:Since tokio-uring needs to inject a driver into the runtime to utilize io_uring, is it possible to support this with tokio or will I just need to replace this with
tokio_uring::start(async { ... });
?I ask because after reviewing the builder docs it doesn't appear that we have options like
worker_threads
,on_thread_start
, andon_thread_stop
to initialize the tokio_uring runtime with.Would it be possible to nest the tokio-uring runtime within a standard tokio runtime like so for ad hoc file operations?
I'm sure nested async runtimes are against best practice, but I wanted to reach out here and get consensus of how others are integrating tokio-uring into their projects if they depended on the standard tokio builder options. I may be overthinking this or missing something. Any pointers in the right direction would be helpful.
The text was updated successfully, but these errors were encountered: