Compare commits
2 commits
0acce0cd46
...
918f11598a
Author | SHA1 | Date | |
---|---|---|---|
918f11598a | |||
f44ab92299 |
2 changed files with 11 additions and 4 deletions
|
@ -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
9
readme.md
Normal 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
|
Loading…
Reference in a new issue