mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-04 11:26:09 +00:00
servo: Merge #16116 - Remove some useless thread spawning in websocket_loader (from nox:tungstenite); r=Wafflespeanut
Source-Repo: https://github.com/servo/servo Source-Revision: 3f10d510bd14b19badbd0c4a5f912b044cdfe890 --HG-- extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear extra : subtree_revision : 2423a5b04f7ed402de6fe178f764dc1a6ddd5be3
This commit is contained in:
parent
361ed3a53c
commit
7addc89506
1
servo/Cargo.lock
generated
1
servo/Cargo.lock
generated
@ -1755,7 +1755,6 @@ dependencies = [
|
||||
"parse-hosts 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 0.9.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 0.9.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"servo-websocket 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"servo_config 0.0.1",
|
||||
"servo_url 0.0.1",
|
||||
"url 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -161,29 +161,24 @@ pub fn init(connect: WebSocketCommunicate, connect_data: WebSocketConnectData, c
|
||||
}
|
||||
});
|
||||
|
||||
let initiated_close_outgoing = initiated_close.clone();
|
||||
let ws_sender_outgoing = ws_sender.clone();
|
||||
let resource_action_receiver = connect.action_receiver;
|
||||
thread::spawn(move || {
|
||||
while let Ok(dom_action) = resource_action_receiver.recv() {
|
||||
match dom_action {
|
||||
WebSocketDomAction::SendMessage(MessageData::Text(data)) => {
|
||||
ws_sender_outgoing.lock().unwrap().send_message(&Message::text(data)).unwrap();
|
||||
},
|
||||
WebSocketDomAction::SendMessage(MessageData::Binary(data)) => {
|
||||
ws_sender_outgoing.lock().unwrap().send_message(&Message::binary(data)).unwrap();
|
||||
},
|
||||
WebSocketDomAction::Close(code, reason) => {
|
||||
if !initiated_close_outgoing.fetch_or(true, Ordering::SeqCst) {
|
||||
let message = match code {
|
||||
Some(code) => Message::close_because(code, reason.unwrap_or("".to_owned())),
|
||||
None => Message::close()
|
||||
};
|
||||
ws_sender_outgoing.lock().unwrap().send_message(&message).unwrap();
|
||||
}
|
||||
},
|
||||
}
|
||||
while let Ok(dom_action) = connect.action_receiver.recv() {
|
||||
match dom_action {
|
||||
WebSocketDomAction::SendMessage(MessageData::Text(data)) => {
|
||||
ws_sender.lock().unwrap().send_message(&Message::text(data)).unwrap();
|
||||
},
|
||||
WebSocketDomAction::SendMessage(MessageData::Binary(data)) => {
|
||||
ws_sender.lock().unwrap().send_message(&Message::binary(data)).unwrap();
|
||||
},
|
||||
WebSocketDomAction::Close(code, reason) => {
|
||||
if !initiated_close.fetch_or(true, Ordering::SeqCst) {
|
||||
let message = match code {
|
||||
Some(code) => Message::close_because(code, reason.unwrap_or("".to_owned())),
|
||||
None => Message::close()
|
||||
};
|
||||
ws_sender.lock().unwrap().send_message(&message).unwrap();
|
||||
}
|
||||
},
|
||||
}
|
||||
});
|
||||
}
|
||||
}).expect("Thread spawning failed");
|
||||
}
|
||||
|
@ -26,7 +26,6 @@ serde = "0.9"
|
||||
serde_derive = "0.9"
|
||||
servo_config = {path = "../config", features = ["servo"]}
|
||||
servo_url = {path = "../url", features = ["servo"]}
|
||||
servo-websocket = "0.18"
|
||||
url = {version = "1.2", features = ["heap_size"]}
|
||||
uuid = {version = "0.4", features = ["v4", "serde"]}
|
||||
webrender_traits = {git = "https://github.com/servo/webrender", features = ["ipc"]}
|
||||
|
@ -31,7 +31,6 @@ extern crate servo_url;
|
||||
extern crate url;
|
||||
extern crate uuid;
|
||||
extern crate webrender_traits;
|
||||
extern crate websocket;
|
||||
|
||||
use cookie_rs::Cookie;
|
||||
use filemanager_thread::FileManagerThreadMsg;
|
||||
@ -47,7 +46,6 @@ use request::{Request, RequestInit};
|
||||
use response::{HttpsState, Response};
|
||||
use servo_url::ServoUrl;
|
||||
use storage_thread::StorageThreadMsg;
|
||||
use websocket::header;
|
||||
|
||||
pub mod blob_url_store;
|
||||
pub mod filemanager_thread;
|
||||
|
Loading…
Reference in New Issue
Block a user