1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
#[cfg(feature = "tokio")]
mod side_a;
#[cfg(feature = "tokio")]
mod side_b;
#[cfg(feature = "tokio")]
#[tokio::main]
async fn main() -> std::io::Result<()> {
use tokio::{sync::oneshot, task};
let (htx, hrx) = oneshot::channel();
let jh = task::spawn(side_a::emain(htx));
let handle = hrx.await.unwrap();
side_b::emain(handle).await?;
jh.await.unwrap()
}
#[cfg(not(feature = "tokio"))]
fn main() {
eprintln!("This example is not available when the Tokio feature is disabled.");
}
|