use std::{cell::RefCell, future::Future}; use criterion::async_executor::AsyncExecutor; pub struct MonoioRuntime(RefCell>); impl Default for MonoioRuntime { fn default() -> Self { Self::new() } } impl MonoioRuntime { pub fn new() -> Self { Self(RefCell::new( monoio::RuntimeBuilder::::new() .build() .unwrap(), )) } } impl AsyncExecutor for MonoioRuntime { fn block_on(&self, future: impl Future) -> T { self.0.borrow_mut().block_on(future) } } impl AsyncExecutor for &MonoioRuntime { fn block_on(&self, future: impl Future) -> T { self.0.borrow_mut().block_on(future) } }