Gracefully Winding Down a C++ Library’s Resources From Rust (with an Async Twist)
Attribution: Claireneon, https://customneon.co.uk/

Gracefully Winding Down a C++ Library’s Resources From Rust (with an Async Twist)

When implementing the uP-L1 Transport library over top of Connected Vehicle Systems Alliance (COVESA) 's vsomeip, I made the choice as pointed out in another article to protect access to mutations of vsomeip state by protecting access behind a dedicated set of threads, one per vsomeip application and used Rust's tokio async framework and channels to communicate to those dedicated threads those mutation commands.

Oftentimes in Rust, if all resources are being managed by the borrow checker, they will be dropped appropriately and no resources will leak. However, in this case resources are owned by a C++ library we need to wind down appropriately.

The twist is that since the Drop impl we must write to clean them up is not async, but we're using an async framework to dispatch work to vsomeip, we end up having to do a bit of careful juggling to ensure we can also shut down the tokio::runtime::Runtime.

Read on for the details! ??

https://petelevasseur.com/articles/018-gracefully-cpp-interop-drop-impl.html

要查看或添加评论,请登录

Pete LeVasseur的更多文章

社区洞察

其他会员也浏览了