Skip to content

Instantly share code, notes, and snippets.

View gterzian's full-sized avatar

Gregory Terzian gterzian

View GitHub Profile
#[test]
fn fourth() {
enum WorkMsg {
Work(u8),
Exit,
}
#[derive(Debug, Eq, PartialEq)]
enum WorkPerformed {
FromCache,
#[test]
fn third() {
enum WorkMsg {
Work(u8),
Exit,
}
enum ResultMsg {
Result(u8),
Exited,
#[test]
fn second() {
enum WorkMsg {
Work(u8),
Exit,
}
enum ResultMsg {
Result(u8),
Exited,
#[test]
fn first() {
/// The messages sent from the "main" component,
/// to the other component running in parallel.
enum WorkMsg {
Work(u8),
Exit,
}
/// The messages sent from the "parallel" component,
/// Content process entry point.
pub fn run_content_process(token: String) {
// Same stuff as before here...
let unprivileged_content = unprivileged_content_receiver.recv().unwrap();
match unprivileged_content {
UnprivilegedContent::Pipeline(mut content) => {
content.start_all();
},
struct Constellation {
/// A map of origin to sender to a Service worker manager.
sw_managers: HashMap<ImmutableOrigin, IpcSender<ServiceWorkerMsg>>,
}
impl Constellation {
fn handle_register_serviceworker(&mut self, scope_things: ScopeThings, scope: ServoUrl) {
let origin = scope.origin();
if let Some(mgr) = self.sw_managers.get(&origin) {
/// Content process entry point, contains init of service worker manager.
pub fn run_content_process(token: String) {
// Same stuff as before here...
// send the required channels to the service worker manager
let sw_senders = unprivileged_content.swmanager_senders();
script::init_service_workers(sw_senders);
unprivileged_content.start_all();
/// Content process entry point.
pub fn run_content_process(token: String) {
let (unprivileged_content_sender, unprivileged_content_receiver) =
ipc::channel::<UnprivilegedContent>().unwrap();
let connection_bootstrap: IpcSender<IpcSender<UnprivilegedContent>> =
IpcSender::connect(token).unwrap();
connection_bootstrap
.send(unprivileged_content_sender)
.unwrap();
#[cfg(any(
target_os = "android",
target_arch = "arm",
all(target_arch = "aarch64", not(target_os = "windows"))
))]
pub fn spawn_multiprocess(content: UnprivilegedContent) -> Result<(), Error> {
use ipc_channel::ipc::{IpcOneShotServer, IpcSender};
// Note that this function can panic, due to process creation,
// avoiding this panic would require a mechanism for dealing
// with low-resource scenarios.
let (script_chan, script_port) = ipc::channel().expect("Pipeline script chan");
let mut unprivileged_pipeline_content = UnprivilegedPipelineContent {
script_port,
// bunch of other stuff needed to start the event-loop...
};
// Spawn the child process.
//
// Yes, that's all there is to it!