rust-firecracker/fctools

Stateful runtimes

Closed this issue · 3 comments

Instead of functions accepting <R: Runtime> and then using something like R::Filesystem::check_exists without &self to perform ops with the runtime, accept <R: Runtime> and a Arc<R> and then runtime.filesystem().check_exists().

The why: be able to store async_executor::Executor-s and such inside the runtime at the cost of an Arc's overhead, which should be negligible.

Release target: 0.6.0-alpha.6 with some extra fixes.

A better idea: force Runtime: Clone to not even have to use an Arc, so that ZST runtimes like Tokio have no overhead whatsoever (the compiler can optimize away no-op clone impls). Those with internal state can just add Arc-s or Arc<Mutex>-es internally and derive Clone.