mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
properly shutdown dedicated workers when the owning scope shuts-down
This commit is contained in:
parent
5174739244
commit
6f34b52e39
3 changed files with 13 additions and 3 deletions
|
@ -460,6 +460,7 @@ impl DedicatedWorkerGlobalScope {
|
||||||
parent_sender,
|
parent_sender,
|
||||||
CommonScriptMsg::CollectReports,
|
CommonScriptMsg::CollectReports,
|
||||||
);
|
);
|
||||||
|
scope.clear_js_runtime();
|
||||||
})
|
})
|
||||||
.expect("Thread spawning failed")
|
.expect("Thread spawning failed")
|
||||||
}
|
}
|
||||||
|
|
|
@ -794,9 +794,18 @@ impl GlobalScope {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Remove the routers for ports and broadcast-channels.
|
/// Remove the routers for ports and broadcast-channels.
|
||||||
pub fn remove_web_messaging_infra(&self) {
|
/// Drain the list of workers.
|
||||||
|
pub fn remove_web_messaging_and_dedicated_workers_infra(&self) {
|
||||||
self.remove_message_ports_router();
|
self.remove_message_ports_router();
|
||||||
self.remove_broadcast_channel_router();
|
self.remove_broadcast_channel_router();
|
||||||
|
|
||||||
|
// Drop each ref to a worker explicitly now,
|
||||||
|
// which will send a shutdown signal,
|
||||||
|
// and join on the worker thread.
|
||||||
|
self.list_auto_close_worker
|
||||||
|
.borrow_mut()
|
||||||
|
.drain(0..)
|
||||||
|
.for_each(|worker| drop(worker));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Update our state to un-managed,
|
/// Update our state to un-managed,
|
||||||
|
|
|
@ -1441,8 +1441,8 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn clear_js_runtime(&self) {
|
pub fn clear_js_runtime(&self) {
|
||||||
// Remove the infra for managing messageports and broadcast channels.
|
self.upcast::<GlobalScope>()
|
||||||
self.upcast::<GlobalScope>().remove_web_messaging_infra();
|
.remove_web_messaging_and_dedicated_workers_infra();
|
||||||
|
|
||||||
// Clean up any active promises
|
// Clean up any active promises
|
||||||
// https://github.com/servo/servo/issues/15318
|
// https://github.com/servo/servo/issues/15318
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue