mirror of
https://github.com/servo/servo.git
synced 2025-09-10 06:58:21 +01:00
Port ScriptToConstellation channel to generic channel (#38990)
This change was previously part of
fb1c0a4c48
, which got reverted due to an
issue
with the compositor channel.
Split this change out into a separate PR, as it probably should have
been in the first place. Presumably it was one change before, since
serialization of crossbeam generic channels in single-process mode was
not implemented yet at the time.
Testing: Covered by existing tests. No custom callbacks involved.
Part of #38912
Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
This commit is contained in:
parent
c4a69abe30
commit
20e955277a
4 changed files with 9 additions and 11 deletions
|
@ -290,7 +290,7 @@ pub struct Constellation<STF, SWF> {
|
||||||
|
|
||||||
/// An IPC channel for script threads to send messages to the constellation.
|
/// An IPC channel for script threads to send messages to the constellation.
|
||||||
/// This is the script threads' view of `script_receiver`.
|
/// This is the script threads' view of `script_receiver`.
|
||||||
script_sender: IpcSender<(PipelineId, ScriptToConstellationMessage)>,
|
script_sender: GenericSender<(PipelineId, ScriptToConstellationMessage)>,
|
||||||
|
|
||||||
/// A channel for the constellation to receive messages from script threads.
|
/// A channel for the constellation to receive messages from script threads.
|
||||||
/// This is the constellation's view of `script_sender`.
|
/// This is the constellation's view of `script_sender`.
|
||||||
|
@ -607,11 +607,8 @@ where
|
||||||
.name("Constellation".to_owned())
|
.name("Constellation".to_owned())
|
||||||
.spawn(move || {
|
.spawn(move || {
|
||||||
let (script_ipc_sender, script_ipc_receiver) =
|
let (script_ipc_sender, script_ipc_receiver) =
|
||||||
ipc::channel().expect("ipc channel failure");
|
generic_channel::channel().expect("ipc channel failure");
|
||||||
let script_receiver =
|
let script_receiver = script_ipc_receiver.route_preserving_errors();
|
||||||
route_ipc_receiver_to_new_crossbeam_receiver_preserving_errors(
|
|
||||||
script_ipc_receiver,
|
|
||||||
);
|
|
||||||
|
|
||||||
let (namespace_ipc_sender, namespace_ipc_receiver) =
|
let (namespace_ipc_sender, namespace_ipc_receiver) =
|
||||||
generic_channel::channel().expect("ipc channel failure");
|
generic_channel::channel().expect("ipc channel failure");
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use base::generic_channel::GenericSender;
|
||||||
use base::id::PipelineId;
|
use base::id::PipelineId;
|
||||||
use constellation_traits::{ScriptToConstellationChan, ScriptToConstellationMessage};
|
use constellation_traits::{ScriptToConstellationChan, ScriptToConstellationMessage};
|
||||||
use crossbeam_channel::Sender;
|
use crossbeam_channel::Sender;
|
||||||
|
@ -196,7 +197,7 @@ pub(crate) struct WorkletGlobalScopeInit {
|
||||||
/// Channel to devtools
|
/// Channel to devtools
|
||||||
pub(crate) devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
|
pub(crate) devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
|
||||||
/// Messages to send to constellation
|
/// Messages to send to constellation
|
||||||
pub(crate) to_constellation_sender: IpcSender<(PipelineId, ScriptToConstellationMessage)>,
|
pub(crate) to_constellation_sender: GenericSender<(PipelineId, ScriptToConstellationMessage)>,
|
||||||
/// The image cache
|
/// The image cache
|
||||||
pub(crate) image_cache: Arc<dyn ImageCache>,
|
pub(crate) image_cache: Arc<dyn ImageCache>,
|
||||||
/// Identity manager for WebGPU resources
|
/// Identity manager for WebGPU resources
|
||||||
|
|
|
@ -340,7 +340,7 @@ pub(crate) struct ScriptThreadSenders {
|
||||||
/// particular pipelines.
|
/// particular pipelines.
|
||||||
#[no_trace]
|
#[no_trace]
|
||||||
pub(crate) pipeline_to_constellation_sender:
|
pub(crate) pipeline_to_constellation_sender:
|
||||||
IpcSender<(PipelineId, ScriptToConstellationMessage)>,
|
GenericSender<(PipelineId, ScriptToConstellationMessage)>,
|
||||||
|
|
||||||
/// The shared [`IpcSender`] which is sent to the `ImageCache` when requesting an image. The
|
/// The shared [`IpcSender`] which is sent to the `ImageCache` when requesting an image. The
|
||||||
/// messages on this channel are routed to crossbeam [`Sender`] on the router thread, which
|
/// messages on this channel are routed to crossbeam [`Sender`] on the router thread, which
|
||||||
|
|
|
@ -8,6 +8,7 @@ use std::collections::HashMap;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
use base::Epoch;
|
use base::Epoch;
|
||||||
|
use base::generic_channel::{GenericSender, SendResult};
|
||||||
use base::id::{
|
use base::id::{
|
||||||
BroadcastChannelRouterId, BrowsingContextId, HistoryStateId, MessagePortId,
|
BroadcastChannelRouterId, BrowsingContextId, HistoryStateId, MessagePortId,
|
||||||
MessagePortRouterId, PipelineId, ServiceWorkerId, ServiceWorkerRegistrationId, WebViewId,
|
MessagePortRouterId, PipelineId, ServiceWorkerId, ServiceWorkerRegistrationId, WebViewId,
|
||||||
|
@ -23,7 +24,6 @@ use embedder_traits::{
|
||||||
use euclid::default::Size2D as UntypedSize2D;
|
use euclid::default::Size2D as UntypedSize2D;
|
||||||
use fonts_traits::SystemFontServiceProxySender;
|
use fonts_traits::SystemFontServiceProxySender;
|
||||||
use http::{HeaderMap, Method};
|
use http::{HeaderMap, Method};
|
||||||
use ipc_channel::Error as IpcError;
|
|
||||||
use ipc_channel::ipc::{IpcReceiver, IpcSender};
|
use ipc_channel::ipc::{IpcReceiver, IpcSender};
|
||||||
use malloc_size_of_derive::MallocSizeOf;
|
use malloc_size_of_derive::MallocSizeOf;
|
||||||
use net_traits::policy_container::PolicyContainer;
|
use net_traits::policy_container::PolicyContainer;
|
||||||
|
@ -48,14 +48,14 @@ use crate::{
|
||||||
#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize)]
|
#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize)]
|
||||||
pub struct ScriptToConstellationChan {
|
pub struct ScriptToConstellationChan {
|
||||||
/// Sender for communicating with constellation thread.
|
/// Sender for communicating with constellation thread.
|
||||||
pub sender: IpcSender<(PipelineId, ScriptToConstellationMessage)>,
|
pub sender: GenericSender<(PipelineId, ScriptToConstellationMessage)>,
|
||||||
/// Used to identify the origin of the message.
|
/// Used to identify the origin of the message.
|
||||||
pub pipeline_id: PipelineId,
|
pub pipeline_id: PipelineId,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ScriptToConstellationChan {
|
impl ScriptToConstellationChan {
|
||||||
/// Send ScriptMsg and attach the pipeline_id to the message.
|
/// Send ScriptMsg and attach the pipeline_id to the message.
|
||||||
pub fn send(&self, msg: ScriptToConstellationMessage) -> Result<(), IpcError> {
|
pub fn send(&self, msg: ScriptToConstellationMessage) -> SendResult {
|
||||||
self.sender.send((self.pipeline_id, msg))
|
self.sender.send((self.pipeline_id, msg))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue