From c13c1c8c6855513cecdf08be677cd99c9b55cdbd Mon Sep 17 00:00:00 2001 From: AzureMarker Date: Tue, 1 Feb 2022 17:07:43 -0800 Subject: [PATCH] Run executor thread on system core --- ctru-rs/examples/futures-basic.rs | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/ctru-rs/examples/futures-basic.rs b/ctru-rs/examples/futures-basic.rs index 5cac1fb..77d20ca 100644 --- a/ctru-rs/examples/futures-basic.rs +++ b/ctru-rs/examples/futures-basic.rs @@ -22,20 +22,23 @@ fn main() { let (exit_sender, mut exit_receiver) = futures::channel::oneshot::channel(); let (mut timer_sender, mut timer_receiver) = futures::channel::mpsc::channel(0); - let executor_thread = ctru::thread::spawn(move || { - let mut executor = futures::executor::LocalPool::new(); + let executor_thread = ctru::thread::Builder::new() + .affinity(1) + .spawn(move || { + let mut executor = futures::executor::LocalPool::new(); - executor.run_until(async move { - loop { - futures::select! { - _ = exit_receiver => break, - _ = timer_receiver.next() => { - println!("Tick"); + executor.run_until(async move { + loop { + futures::select! { + _ = exit_receiver => break, + _ = timer_receiver.next() => { + println!("Tick"); + } } } - } - }); - }); + }); + }) + .expect("Failed to create executor thread"); println!("Executor started!");