According to Alice's blog, when you running forever you should use a dedicated thread, but I also need a lot of tokio features like channels in my program, the program looks like:
#[tokio::main]
async fn main() {
loop {
// total sync code
let result = processing();
// some other place handing
sender.send(result)
}
}
should I remove tokio and make my code all synchronous?
#[tokio::main]
async fn main() {
loop {
let (data1, data2) = (capture_data(), capture_data());
// total sync code
let result = processing(data1, data2);
// some other place handing
let handle1 = handle_data_spawn(data1);
let handle2 = handle_data_spawn(data2);
let handle3 = handle_data_spawn(result);
wait_for(handle1, handle2, handle3)
}
}