1
Fork 0

Compare commits

..

No commits in common. "918f11598a5064d8063dc3f79b2c9e7d685180a0" and "0acce0cd46492f0877cf5d7f7644bfd4c81e80f4" have entirely different histories.

2 changed files with 4 additions and 11 deletions

View file

@ -11,10 +11,12 @@ async fn main() -> Result<()> {
let (tx,rx) = oneshot::channel(); 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: 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 fut = unsafe{func(12,54, rx)};
let out = tokio::spawn(fut); let out = tokio::spawn(async move {
fut.await
});
tx.send(8).unwrap(); tx.send(8).unwrap();

View file

@ -1,9 +0,0 @@
# 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