Macros for efficient development
Examples
Spawns a new asynchronous task, returning a JoinHandle for it.
async
Runs the provided closure on a thread where blocking is acceptable.
async
executed on the async code in sync
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
poee::spawn(||{
std::fs::write("demo0", "rust").unwrap();
});
fn demo(){
std::fs::write("demo1", "rust").unwrap();
}
poee::spawn(demo);
Ok(())
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
poee::spawn_blocking(||{
std::fs::write("demo0", "rust").unwrap();
});
fn demo(){
std::fs::write("demo1", "rust").unwrap();
}
poee::spawn_blocking(demo);
Ok(())
}
fn main(){
async fn demo(){
println!("demo");
}
poee::sync_fn(demo());
}