@raviqqe
go
std::thread::spawn()
tokio::spawn()
func main() { go func() { doSomething() }() }
\(\() T) \() T
\(\() any) \() any
main = \() { future = go \() number { doSomething() } ... }
os
#[no_mangle] extern "C" fn _pen_spawn(closure: ffi::Arc<ffi::Closure>) -> ffi::Arc<ffi::Closure> { ffi::future::to_closure(spawn_and_unwrap(ffi::future::from_closure(closure))) } async fn spawn_and_unwrap<F: Future<Output = ffi::Any> + Send + 'static>(future: F) -> ffi::Any { spawn(future).await.unwrap() }
std::future::Future
#[ffi::any] struct Foo { ... }
#[ffi::bindgen] fn foo() { ... } #[ffi::bindgen] async fn foo() { ... }
ffi::future::to_closure<O, F: Future<Output = O>>(future: F) -> ffi::Arc<ffi::Closure>
async ffi::future::from_closure<T>(closure: ffi::Arc<ffi::Closure>) -> T