create the ctrlc handler directly around the PluginInterface and stash the guard on RunningPlugin
this looks much better will back out the changes to PluginGc
This commit is contained in:
parent
e194218169
commit
34acc251ff
|
@ -50,6 +50,8 @@ struct RunningPlugin {
|
||||||
interface: PluginInterface,
|
interface: PluginInterface,
|
||||||
/// Garbage collector for the plugin
|
/// Garbage collector for the plugin
|
||||||
gc: PluginGc,
|
gc: PluginGc,
|
||||||
|
/// todo: docs
|
||||||
|
_ctrlc_guard: Option<ctrlc::Guard>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PersistentPlugin {
|
impl PersistentPlugin {
|
||||||
|
@ -212,7 +214,14 @@ impl PersistentPlugin {
|
||||||
return self.spawn(envs, mutable, ctrlc_handlers);
|
return self.spawn(envs, mutable, ctrlc_handlers);
|
||||||
}
|
}
|
||||||
|
|
||||||
mutable.running = Some(RunningPlugin { interface, gc });
|
let guard = ctrlc_handlers.map(|ctrlc_handlers| {
|
||||||
|
let interface = interface.clone();
|
||||||
|
ctrlc_handlers.add(Box::new(move || {
|
||||||
|
let _ = interface.ctrlc();
|
||||||
|
}))
|
||||||
|
});
|
||||||
|
|
||||||
|
mutable.running = Some(RunningPlugin { interface, gc, _ctrlc_guard: guard});
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -322,6 +322,10 @@ impl InterfaceManager for EngineInterfaceManager {
|
||||||
});
|
});
|
||||||
self.send_engine_call_response(id, response)
|
self.send_engine_call_response(id, response)
|
||||||
}
|
}
|
||||||
|
PluginInput::Ctrlc => {
|
||||||
|
eprintln!("Received Ctrl-C!");
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user