tokio_shared/handle.rs
1use tokio::runtime::EnterGuard;
2
3// The trait MyDrop is important to make sure the Drop::drop is tied to where it got entered(in dylib)
4// otherwise the main executable will try to call the main EnterGuard handler
5trait MyDrop<'a> {}
6impl<'a> MyDrop<'a> for EnterGuard<'a> {}
7pub struct TokioEnterGuard<'a> {
8 _guard: Box<dyn MyDrop<'a> + 'a>,
9}
10
11impl<'a> TokioEnterGuard<'a> {
12 pub(crate) fn new(guard: EnterGuard<'a>) -> Self {
13 let guard = Box::new(guard) as Box<dyn MyDrop<'a> + 'a>;
14
15 Self { _guard: guard }
16 }
17}