mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Auto merge of #11373 - servo:threadfactory, r=larsbergstrom
Use associated types to improve LayoutThreadFactory and ScriptThreadFactory. Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy --faster` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). Either: - [ ] There are tests for these changes OR - [x] These changes do not require tests because refactoring Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11373) <!-- Reviewable:end -->
This commit is contained in:
commit
586c0702a0
8 changed files with 47 additions and 78 deletions
|
@ -90,7 +90,7 @@ enum ReadyToSave {
|
|||
/// `ScriptThreadFactory` (which in practice are implemented by
|
||||
/// `LayoutThread` in the `layout` crate, and `ScriptThread` in
|
||||
/// the `script` crate).
|
||||
pub struct Constellation<LTF, STF> {
|
||||
pub struct Constellation<Message, LTF, STF> {
|
||||
/// A channel through which script messages can be sent to this object.
|
||||
script_sender: IpcSender<FromScriptMsg>,
|
||||
|
||||
|
@ -167,7 +167,7 @@ pub struct Constellation<LTF, STF> {
|
|||
/// A channel through which messages can be sent to the memory profiler.
|
||||
mem_profiler_chan: mem::ProfilerChan,
|
||||
|
||||
phantom: PhantomData<(LTF, STF)>,
|
||||
phantom: PhantomData<(Message, LTF, STF)>,
|
||||
|
||||
window_size: WindowSizeData,
|
||||
|
||||
|
@ -319,7 +319,10 @@ enum ChildProcess {
|
|||
Unsandboxed(process::Child),
|
||||
}
|
||||
|
||||
impl<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF> {
|
||||
impl<Message, LTF, STF> Constellation<Message, LTF, STF>
|
||||
where LTF: LayoutThreadFactory<Message=Message>,
|
||||
STF: ScriptThreadFactory<Message=Message>
|
||||
{
|
||||
pub fn start(state: InitialConstellationState) -> Sender<FromCompositorMsg> {
|
||||
let (ipc_script_sender, ipc_script_receiver) = ipc::channel().expect("ipc channel failure");
|
||||
let script_receiver = ROUTER.route_ipc_receiver_to_new_mpsc_receiver(ipc_script_receiver);
|
||||
|
@ -334,7 +337,7 @@ impl<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF>
|
|||
let compositor_sender_clone = compositor_sender.clone();
|
||||
|
||||
spawn_named("Constellation".to_owned(), move || {
|
||||
let mut constellation: Constellation<LTF, STF> = Constellation {
|
||||
let mut constellation: Constellation<Message, LTF, STF> = Constellation {
|
||||
script_sender: ipc_script_sender,
|
||||
compositor_sender: compositor_sender_clone,
|
||||
layout_sender: ipc_layout_sender,
|
||||
|
@ -456,7 +459,7 @@ impl<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF>
|
|||
if opts::multiprocess() {
|
||||
self.spawn_multiprocess(pipeline_id, unprivileged_pipeline_content);
|
||||
} else {
|
||||
unprivileged_pipeline_content.start_all::<LTF, STF>(false);
|
||||
unprivileged_pipeline_content.start_all::<Message, LTF, STF>(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue