mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00: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
|
@ -45,7 +45,6 @@ use crate::fetch::{create_a_potential_cors_request, FetchCanceller};
|
|||
use crate::network_listener::{self, NetworkListener, PreInvoke, ResourceTimingListener};
|
||||
use crate::realms::enter_realm;
|
||||
use crate::script_runtime::CanGc;
|
||||
use crate::task_source::TaskSourceName;
|
||||
use crate::timers::OneshotTimerCallback;
|
||||
|
||||
const DEFAULT_RECONNECTION_TIME: Duration = Duration::from_millis(5000);
|
||||
|
@ -121,7 +120,6 @@ impl EventSourceContext {
|
|||
event_source.upcast::<EventTarget>().fire_event(atom!("open"), CanGc::note());
|
||||
}
|
||||
}),
|
||||
&global,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -177,7 +175,6 @@ impl EventSourceContext {
|
|||
// FIXME(nox): Why are errors silenced here?
|
||||
let _ = event_source.global().schedule_callback(callback, duration);
|
||||
}),
|
||||
&global,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -266,7 +263,6 @@ impl EventSourceContext {
|
|||
event.root().upcast::<Event>().fire(event_source.upcast(), CanGc::note());
|
||||
}
|
||||
}),
|
||||
&global,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -508,7 +504,6 @@ impl EventSource {
|
|||
event_source.upcast::<EventTarget>().fire_event(atom!("error"), CanGc::note());
|
||||
}
|
||||
}),
|
||||
&global,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -606,7 +601,6 @@ impl EventSourceMethods<crate::DomTypeHolder> for EventSource {
|
|||
let listener = NetworkListener {
|
||||
context: Arc::new(Mutex::new(context)),
|
||||
task_source: global.task_manager().networking_task_source(),
|
||||
canceller: Some(global.task_canceller(TaskSourceName::Networking)),
|
||||
};
|
||||
ROUTER.add_typed_route(
|
||||
action_receiver,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue