MCPcopy Create free account
hub / github.com/Botloader/botloader / run

Method run

components/vm/src/vm.rs:208–255  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

206 }
207
208 pub async fn run(&mut self) {
209 self.emit_isolate_handle();
210
211 info!("running runtime");
212 self.guild_logger
213 .log(CreateLogEntry::info("guild vm started".to_string()));
214
215 let mut completed = false;
216 while !self.check_terminated() {
217 let fut = TickFuture {
218 rx: &mut self.rx,
219 rt: &mut self.runtime,
220 wakeup: &mut self.wakeup_rx,
221 completed,
222 };
223
224 completed = false;
225
226 match fut.await {
227 TickResult::Command(Some(cmd)) => {
228 self.handle_cmd(cmd).await;
229 }
230 TickResult::Command(None) => {
231 // sender was dropped, shut ourselves down?
232 }
233 TickResult::Continue => {}
234 TickResult::VmError(e) => {
235 self.guild_logger.log(CreateLogEntry::error(format!(
236 "Script error occurred: {}",
237 e
238 )));
239 }
240 TickResult::Completed => {
241 let _ = self.tx.send(VmEvent::VmFinished);
242 completed = true;
243 }
244 }
245 }
246
247 info!("terminating runtime for guild");
248
249 let shutdown_reason = { self.shutdown_handle.read_shutdown_reason() };
250
251 if let Some(ShutdownReason::Request) = shutdown_reason {
252 // cleanly finish the futures
253 self.stop_vm().await;
254 }
255 }
256
257 fn check_terminated(&mut self) -> bool {
258 self.shutdown_handle

Callers 7

create_runMethod · 0.45
saveFunction · 0.45
test.jsFile · 0.45
buildFunction · 0.45
run_full_benchFunction · 0.45
newMethod · 0.45
runFunction · 0.45

Calls 8

errorFunction · 0.85
emit_isolate_handleMethod · 0.80
logMethod · 0.80
check_terminatedMethod · 0.80
read_shutdown_reasonMethod · 0.80
stop_vmMethod · 0.80
handle_cmdMethod · 0.45
sendMethod · 0.45

Tested by

no test coverage detected