mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
script: Move TaskManager
to GlobalScope
(#34827)
This is a simplification of the internal `TaskQueue` API that moves the `TaskManager` to the `GlobalScope` itself. In addition, the handling of cancellers is moved to the `TaskManager` as well. This means that no arguments other than the `task` are necessary for queueing tasks, which makes the API a lot easier to use and cleaner. `TaskSource` now also keeps a copy of the canceller with it, so that they always know the proper way to cancel any tasks queued on them. There is one complication here. The event loop `sender` for dedicated workers is constantly changing as it is set to `None` when not handling messages. This is because this sender keeps a handle to the main thread's `Worker` object, preventing garbage collection while any messages are still in flight or being handled. This change allows setting the `sender` on the `TaskManager` to `None` to allow proper garbabge collection. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
75a22cfe2e
commit
b2eda71952
54 changed files with 1060 additions and 1516 deletions
|
@ -147,13 +147,10 @@ impl XRTestMethods<crate::DomTypeHolder> for XRTest {
|
|||
};
|
||||
|
||||
let global = self.global();
|
||||
let window = global.as_window();
|
||||
let this = Trusted::new(self);
|
||||
let mut trusted = Some(TrustedPromise::new(p.clone()));
|
||||
|
||||
let (task_source, canceller) = window
|
||||
.task_manager()
|
||||
.dom_manipulation_task_source_with_canceller();
|
||||
let task_source = global.task_manager().dom_manipulation_task_source();
|
||||
let (sender, receiver) = ipc::channel(global.time_profiler_chan().clone()).unwrap();
|
||||
|
||||
ROUTER.add_typed_route(
|
||||
|
@ -166,15 +163,12 @@ impl XRTestMethods<crate::DomTypeHolder> for XRTest {
|
|||
let message =
|
||||
message.expect("SimulateDeviceConnection callback given incorrect payload");
|
||||
|
||||
let _ = task_source.queue_with_canceller(
|
||||
task!(request_session: move || {
|
||||
this.root().device_obtained(message, trusted);
|
||||
}),
|
||||
&canceller,
|
||||
);
|
||||
let _ = task_source.queue(task!(request_session: move || {
|
||||
this.root().device_obtained(message, trusted);
|
||||
}));
|
||||
}),
|
||||
);
|
||||
if let Some(mut r) = window.webxr_registry() {
|
||||
if let Some(mut r) = global.as_window().webxr_registry() {
|
||||
r.simulate_device_connection(init, sender);
|
||||
}
|
||||
|
||||
|
@ -206,10 +200,7 @@ impl XRTestMethods<crate::DomTypeHolder> for XRTest {
|
|||
devices.clear();
|
||||
|
||||
let mut trusted = Some(TrustedPromise::new(p.clone()));
|
||||
let (task_source, canceller) = global
|
||||
.as_window()
|
||||
.task_manager()
|
||||
.dom_manipulation_task_source_with_canceller();
|
||||
let task_source = global.task_manager().dom_manipulation_task_source();
|
||||
|
||||
ROUTER.add_typed_route(
|
||||
receiver.to_ipc_receiver(),
|
||||
|
@ -219,8 +210,7 @@ impl XRTestMethods<crate::DomTypeHolder> for XRTest {
|
|||
let trusted = trusted
|
||||
.take()
|
||||
.expect("DisconnectAllDevices disconnected more devices than expected");
|
||||
let _ =
|
||||
task_source.queue_with_canceller(trusted.resolve_task(()), &canceller);
|
||||
let _ = task_source.queue(trusted.resolve_task(()));
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue