提问人:Vana 提问时间:11/17/2023 最后编辑:Vana 更新时间:11/18/2023 访问量:45
如何从动态库调用异步函数
How to call an asynchronous function from a dynamic library
问:
我使用 dlopen2
将动态库加载到 Rust 应用程序中。
似乎不支持.所以我必须这样做async fn
#[no_mangle]
pub fn run() {
let rt = tokio::runtime::Runtime::new().unwrap();
let join_handle = rt.spawn(async {
mymod::asyncfn().await;
});
rt.block_on(join_handle).unwrap();
}
我像这样加载这个库:
let container: Container<Api> = unsafe { Container::load("plugins/mail/mydynlib.so") }
.expect("Could not open library");
container.run();
我已启用模块的日志。加载我的库时,我希望看到这些日志。我看不见他们。我不明白为什么。
那么,如何从动态库中加载一个。async fn
dlopen2
答: 暂无答案
评论