1
Fork 0

Compare commits

...

2 commits

Author SHA1 Message Date
918f11598a
removed complexity (Send is an illusion) 2024-12-19 12:42:43 -05:00
f44ab92299
added readme 2024-12-19 12:42:37 -05:00
2 changed files with 11 additions and 4 deletions

View file

@ -11,12 +11,10 @@ async fn main() -> Result<()> {
let (tx,rx) = oneshot::channel();
let func: Symbol<unsafe extern fn(u64,u64, Receiver<u64>) -> Pin<Box<dyn Future<Output = u64> + Send>>> = unsafe {lib.get(b"add_wrapper")?};
let func = unsafe{func.into_raw()};
let fut = unsafe{func(12,54, rx)};
let out = tokio::spawn(async move {
fut.await
});
let out = tokio::spawn(fut);
tx.send(8).unwrap();

9
readme.md Normal file
View file

@ -0,0 +1,9 @@
# async hot reloading
minimal example of loading an async function from a `.so` and spawning it on the tokio executor.
the loaded library returns a
```rust
Pin<Box<dyn Future<Output = u64> + Send >>
```
which can be sent directly to tokio