diff options
89 files changed, 341 insertions, 377 deletions
diff --git a/Cargo.lock b/Cargo.lock index af695a18963..99442033f10 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -213,7 +213,7 @@ dependencies = [ "bluetooth_traits 0.0.1", "device 0.0.1 (git+https://github.com/servo/devices)", "embedder_traits 0.0.1", - "ipc-channel 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ipc-channel 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "servo_config 0.0.1", "servo_rand 0.0.1", @@ -225,7 +225,7 @@ name = "bluetooth_traits" version = "0.0.1" dependencies = [ "embedder_traits 0.0.1", - "ipc-channel 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ipc-channel 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -331,7 +331,7 @@ dependencies = [ "euclid 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "gleam 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ipc-channel 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ipc-channel 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "offscreen_gl_context 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -348,7 +348,7 @@ dependencies = [ "cssparser 0.24.0 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", "gleam 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ipc-channel 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ipc-channel 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "malloc_size_of 0.0.1", "malloc_size_of_derive 0.0.1", @@ -505,13 +505,14 @@ dependencies = [ "gfx_traits 0.0.1", "gleam 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "image 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ipc-channel 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ipc-channel 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "msg 0.0.1", "net_traits 0.0.1", "profile_traits 0.0.1", "script_traits 0.0.1", + "servo_channel 0.0.1", "servo_config 0.0.1", "servo_geometry 0.0.1", "servo_url 0.0.1", @@ -540,7 +541,7 @@ dependencies = [ "gfx 0.0.1", "gfx_traits 0.0.1", "hyper 0.10.13 (registry+https://github.com/rust-lang/crates.io-index)", - "ipc-channel 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ipc-channel 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "layout_traits 0.0.1", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "metrics 0.0.1", @@ -550,6 +551,7 @@ dependencies = [ "profile_traits 0.0.1", "script_traits 0.0.1", "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", + "servo_channel 0.0.1", "servo_config 0.0.1", "servo_rand 0.0.1", "servo_remutex 0.0.1", @@ -755,6 +757,7 @@ name = "debugger" version = "0.0.1" dependencies = [ "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "servo_channel 0.0.1", "ws 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -800,11 +803,12 @@ dependencies = [ "devtools_traits 0.0.1", "hyper 0.10.13 (registry+https://github.com/rust-lang/crates.io-index)", "hyper_serde 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ipc-channel 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ipc-channel 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "msg 0.0.1", "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", + "servo_channel 0.0.1", "time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -815,7 +819,7 @@ dependencies = [ "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.10.13 (registry+https://github.com/rust-lang/crates.io-index)", "hyper_serde 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ipc-channel 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ipc-channel 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "malloc_size_of 0.0.1", "malloc_size_of_derive 0.0.1", "msg 0.0.1", @@ -898,11 +902,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "embedder_traits" version = "0.0.1" dependencies = [ - "ipc-channel 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ipc-channel 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "msg 0.0.1", "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", + "servo_channel 0.0.1", "servo_url 0.0.1", "style_traits 0.0.1", "webrender_api 0.57.2 (git+https://github.com/servo/webrender)", @@ -1146,7 +1151,7 @@ dependencies = [ "freetype 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "gfx_traits 0.0.1", "harfbuzz-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "ipc-channel 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ipc-channel 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1654,27 +1659,11 @@ dependencies = [ [[package]] name = "ipc-channel" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bincode 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-channel 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.15 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", - "uuid 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "ipc-channel" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bincode 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-channel 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-channel 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1776,7 +1765,7 @@ dependencies = [ "gfx 0.0.1", "gfx_traits 0.0.1", "html5ever 0.22.3 (registry+https://github.com/rust-lang/crates.io-index)", - "ipc-channel 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ipc-channel 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "malloc_size_of 0.0.1", @@ -1794,6 +1783,7 @@ dependencies = [ "serde_json 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", "servo_arc 0.1.1", "servo_atoms 0.0.1", + "servo_channel 0.0.1", "servo_config 0.0.1", "servo_geometry 0.0.1", "servo_url 0.0.1", @@ -1821,7 +1811,7 @@ dependencies = [ "gfx_traits 0.0.1", "histogram 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", "html5ever 0.22.3 (registry+https://github.com/rust-lang/crates.io-index)", - "ipc-channel 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ipc-channel 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "layout 0.0.1", "layout_traits 0.0.1", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1843,6 +1833,7 @@ dependencies = [ "servo_allocator 0.0.1", "servo_arc 0.1.1", "servo_atoms 0.0.1", + "servo_channel 0.0.1", "servo_config 0.0.1", "servo_geometry 0.0.1", "servo_url 0.0.1", @@ -1857,12 +1848,13 @@ name = "layout_traits" version = "0.0.1" dependencies = [ "gfx 0.0.1", - "ipc-channel 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ipc-channel 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "metrics 0.0.1", "msg 0.0.1", "net_traits 0.0.1", "profile_traits 0.0.1", "script_traits 0.0.1", + "servo_channel 0.0.1", "servo_url 0.0.1", "webrender_api 0.57.2 (git+https://github.com/servo/webrender)", ] @@ -1932,7 +1924,7 @@ dependencies = [ "gaol 0.0.1 (git+https://github.com/servo/gaol)", "gfx 0.0.1", "gleam 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ipc-channel 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ipc-channel 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "layout_thread 0.0.1", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "msg 0.0.1", @@ -2041,6 +2033,7 @@ dependencies = [ "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", "serde_bytes 0.10.4 (registry+https://github.com/rust-lang/crates.io-index)", "servo_arc 0.1.1", + "servo_channel 0.0.1", "smallbitvec 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "string_cache 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2116,7 +2109,7 @@ name = "metrics" version = "0.0.1" dependencies = [ "gfx_traits 0.0.1", - "ipc-channel 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ipc-channel 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "malloc_size_of 0.0.1", "malloc_size_of_derive 0.0.1", @@ -2133,7 +2126,7 @@ name = "metrics_tests" version = "0.0.1" dependencies = [ "gfx_traits 0.0.1", - "ipc-channel 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ipc-channel 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "layout 0.0.1", "metrics 0.0.1", "msg 0.0.1", @@ -2314,7 +2307,7 @@ dependencies = [ "hyper-openssl 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "hyper_serde 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "immeta 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ipc-channel 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ipc-channel 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "malloc_size_of 0.0.1", @@ -2330,6 +2323,7 @@ dependencies = [ "serde_json 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", "servo_allocator 0.0.1", "servo_arc 0.1.1", + "servo_channel 0.0.1", "servo_config 0.0.1", "servo_url 0.0.1", "threadpool 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2360,7 +2354,7 @@ dependencies = [ "hyper 0.10.13 (registry+https://github.com/rust-lang/crates.io-index)", "hyper_serde 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "image 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ipc-channel 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ipc-channel 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "malloc_size_of 0.0.1", @@ -2728,7 +2722,7 @@ version = "0.0.1" dependencies = [ "heartbeats-simple 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "influent 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ipc-channel 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ipc-channel 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "jemalloc-sys 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2745,7 +2739,7 @@ dependencies = [ name = "profile_tests" version = "0.0.1" dependencies = [ - "ipc-channel 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ipc-channel 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "profile 0.0.1", "profile_traits 0.0.1", "servo_allocator 0.0.1", @@ -2759,9 +2753,10 @@ dependencies = [ "bincode 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "energy-monitor 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "energymon 0.3.0 (git+https://github.com/energymon/energymon-rust.git)", - "ipc-channel 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ipc-channel 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", + "servo_channel 0.0.1", "servo_config 0.0.1", "signpost 0.1.0 (git+https://github.com/pcwalton/signpost.git)", "time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2853,7 +2848,7 @@ dependencies = [ "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3011,7 +3006,7 @@ dependencies = [ "hyper 0.10.13 (registry+https://github.com/rust-lang/crates.io-index)", "hyper_serde 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "image 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ipc-channel 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ipc-channel 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)", "jstraceable_derive 0.0.1", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3048,6 +3043,7 @@ dependencies = [ "servo_allocator 0.0.1", "servo_arc 0.1.1", "servo_atoms 0.0.1", + "servo_channel 0.0.1", "servo_config 0.0.1", "servo_geometry 0.0.1", "servo_rand 0.0.1", @@ -3078,7 +3074,7 @@ dependencies = [ "euclid 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", "gfx_traits 0.0.1", "html5ever 0.22.3 (registry+https://github.com/rust-lang/crates.io-index)", - "ipc-channel 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ipc-channel 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "malloc_size_of 0.0.1", @@ -3092,6 +3088,7 @@ dependencies = [ "selectors 0.20.0", "servo_arc 0.1.1", "servo_atoms 0.0.1", + "servo_channel 0.0.1", "servo_url 0.0.1", "style 0.0.1", "time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3132,7 +3129,7 @@ dependencies = [ "gfx_traits 0.0.1", "hyper 0.10.13 (registry+https://github.com/rust-lang/crates.io-index)", "hyper_serde 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ipc-channel 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ipc-channel 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", "malloc_size_of 0.0.1", "malloc_size_of_derive 0.0.1", @@ -3142,6 +3139,7 @@ dependencies = [ "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", "servo_atoms 0.0.1", + "servo_channel 0.0.1", "servo_url 0.0.1", "style_traits 0.0.1", "time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3600,6 +3598,7 @@ dependencies = [ "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", "servo_arc 0.1.1", "servo_atoms 0.0.1", + "servo_channel 0.0.1", "servo_config 0.0.1", "servo_url 0.0.1", "smallbitvec 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4046,13 +4045,14 @@ dependencies = [ "euclid 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.10.13 (registry+https://github.com/rust-lang/crates.io-index)", "image 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ipc-channel 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ipc-channel 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "msg 0.0.1", "net_traits 0.0.1", "regex 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", "script_traits 0.0.1", + "servo_channel 0.0.1", "servo_config 0.0.1", "servo_url 0.0.1", "url 1.6.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4063,7 +4063,7 @@ dependencies = [ [[package]] name = "webrender" version = "0.57.2" -source = "git+https://github.com/servo/webrender#c939a61b83bcc9dc10742977704793e9a85b3858" +source = "git+https://github.com/servo/webrender#38f3b57cd9bf2c6fb736d14832fee87eb576e322" dependencies = [ "app_units 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4098,7 +4098,7 @@ dependencies = [ [[package]] name = "webrender_api" version = "0.57.2" -source = "git+https://github.com/servo/webrender#c939a61b83bcc9dc10742977704793e9a85b3858" +source = "git+https://github.com/servo/webrender#38f3b57cd9bf2c6fb736d14832fee87eb576e322" dependencies = [ "app_units 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "bincode 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4108,7 +4108,7 @@ dependencies = [ "core-graphics 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", "dwrote 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ipc-channel 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ipc-channel 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", "serde_bytes 0.10.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4121,11 +4121,12 @@ version = "0.0.1" dependencies = [ "canvas_traits 0.0.1", "euclid 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ipc-channel 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ipc-channel 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "msg 0.0.1", "rust-webvr 0.9.10 (registry+https://github.com/rust-lang/crates.io-index)", "script_traits 0.0.1", + "servo_channel 0.0.1", "servo_config 0.0.1", "webvr_traits 0.0.1", ] @@ -4134,7 +4135,7 @@ dependencies = [ name = "webvr_traits" version = "0.0.1" dependencies = [ - "ipc-channel 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ipc-channel 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "msg 0.0.1", "rust-webvr-api 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4465,7 +4466,6 @@ dependencies = [ "checksum influent 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a22b311b83431be3ab9af96ca9ea41554bb4a8551ea871ae44c3ce0c57e55f2c" "checksum io-surface 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5f9a33981dff54baaff80f4decb487a65d148a3c00facc97820d0f09128f74dd" "checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" -"checksum ipc-channel 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "db9daf099728ac5390c73f54e6e3708f0c514d2b51f24373830f568702eadfca" "checksum ipc-channel 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dd75debad4ffd295c00c6e3634d254df30050b0837a85e5cd039ac424365f24a" "checksum itertools 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b07332223953b5051bceb67e8c4700aa65291535568e1f12408c43c4a42c0394" "checksum itoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c069bbec61e1ca5a596166e55dfe4773ff745c3d16b700013bcaff9a6df2c682" diff --git a/components/bluetooth/Cargo.toml b/components/bluetooth/Cargo.toml index 1e61283fd3f..91271503090 100644 --- a/components/bluetooth/Cargo.toml +++ b/components/bluetooth/Cargo.toml @@ -14,7 +14,7 @@ bitflags = "1.0" bluetooth_traits = {path = "../bluetooth_traits"} device = {git = "https://github.com/servo/devices", features = ["bluetooth-test"]} embedder_traits = {path = "../embedder_traits"} -ipc-channel = "0.10" +ipc-channel = "0.11" log = "0.4" servo_config = {path = "../config"} servo_rand = {path = "../rand"} diff --git a/components/bluetooth_traits/Cargo.toml b/components/bluetooth_traits/Cargo.toml index 6d432e060d0..5446a996ebf 100644 --- a/components/bluetooth_traits/Cargo.toml +++ b/components/bluetooth_traits/Cargo.toml @@ -10,7 +10,7 @@ name = "bluetooth_traits" path = "lib.rs" [dependencies] -ipc-channel = "0.10" +ipc-channel = "0.11" regex = "1.0" serde = "1.0" embedder_traits = { path = "../embedder_traits" } diff --git a/components/canvas/Cargo.toml b/components/canvas/Cargo.toml index f57bfdab77f..d65c1b4b110 100644 --- a/components/canvas/Cargo.toml +++ b/components/canvas/Cargo.toml @@ -17,7 +17,7 @@ cssparser = "0.24" euclid = "0.19" fnv = "1.0" gleam = "0.6" -ipc-channel = "0.10" +ipc-channel = "0.11" log = "0.4" num-traits = "0.2" offscreen_gl_context = {version = "0.21", features = ["serde", "osmesa"]} diff --git a/components/canvas_traits/Cargo.toml b/components/canvas_traits/Cargo.toml index 60c4ffde41b..b5599232b5c 100644 --- a/components/canvas_traits/Cargo.toml +++ b/components/canvas_traits/Cargo.toml @@ -12,7 +12,7 @@ path = "lib.rs" [dependencies] cssparser = "0.24.0" euclid = "0.19" -ipc-channel = "0.10" +ipc-channel = "0.11" gleam = "0.6" lazy_static = "1" malloc_size_of = { path = "../malloc_size_of" } diff --git a/components/compositing/Cargo.toml b/components/compositing/Cargo.toml index 0dbd2c16961..3f2096d9557 100644 --- a/components/compositing/Cargo.toml +++ b/components/compositing/Cargo.toml @@ -19,13 +19,14 @@ euclid = "0.19" gfx_traits = {path = "../gfx_traits"} gleam = {version = "0.6", optional = true} image = "0.19" -ipc-channel = "0.10" +ipc-channel = "0.11" libc = "0.2" log = "0.4" msg = {path = "../msg"} net_traits = {path = "../net_traits"} profile_traits = {path = "../profile_traits"} script_traits = {path = "../script_traits"} +servo_channel = {path = "../channel"} servo_config = {path = "../config"} servo_geometry = {path = "../geometry"} servo_url = {path = "../url"} diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index 2a4845b6c2a..ae505c935d5 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -23,6 +23,7 @@ use script_traits::{AnimationState, AnimationTickType, ConstellationMsg, LayoutC use script_traits::{MouseButton, MouseEventType, ScrollState, TouchEventType, TouchId}; use script_traits::{UntrustedNodeAddress, WindowSizeData, WindowSizeType}; use script_traits::CompositorEvent::{MouseMoveEvent, MouseButtonEvent, TouchEvent}; +use servo_channel::Sender; use servo_config::opts; use servo_geometry::DeviceIndependentPixel; use std::collections::HashMap; @@ -31,7 +32,6 @@ use std::fs::{File, create_dir_all}; use std::io::Write; use std::num::NonZeroU32; use std::rc::Rc; -use std::sync::mpsc::Sender; use std::time::Instant; use style_traits::{CSSPixel, DevicePixel, PinchZoomFactor}; use style_traits::cursor::CursorKind; @@ -358,7 +358,7 @@ impl<Window: WindowMethods> IOCompositor<Window> { fn start_shutting_down(&mut self) { debug!("Compositor sending Exit message to Constellation"); if let Err(e) = self.constellation_chan.send(ConstellationMsg::Exit) { - warn!("Sending exit message to constellation failed ({}).", e); + warn!("Sending exit message to constellation failed ({:?}).", e); } self.shutdown_state = ShutdownState::ShuttingDown; @@ -420,7 +420,7 @@ impl<Window: WindowMethods> IOCompositor<Window> { } let img = res.unwrap_or(None); if let Err(e) = reply.send(img) { - warn!("Sending reply to create png failed ({}).", e); + warn!("Sending reply to create png failed ({:?}).", e); } }, @@ -494,19 +494,19 @@ impl<Window: WindowMethods> IOCompositor<Window> { (Msg::GetClientWindow(req), ShutdownState::NotShuttingDown) => { if let Err(e) = req.send(self.embedder_coordinates.window) { - warn!("Sending response to get client window failed ({}).", e); + warn!("Sending response to get client window failed ({:?}).", e); } }, (Msg::GetScreenSize(req), ShutdownState::NotShuttingDown) => { if let Err(e) = req.send(self.embedder_coordinates.screen) { - warn!("Sending response to get screen size failed ({}).", e); + warn!("Sending response to get screen size failed ({:?}).", e); } }, (Msg::GetScreenAvailSize(req), ShutdownState::NotShuttingDown) => { if let Err(e) = req.send(self.embedder_coordinates.screen_avail) { - warn!("Sending response to get screen avail size failed ({}).", e); + warn!("Sending response to get screen avail size failed ({:?}).", e); } }, @@ -634,7 +634,7 @@ impl<Window: WindowMethods> IOCompositor<Window> { let msg = ConstellationMsg::WindowSize(top_level_browsing_context_id, data, size_type); if let Err(e) = self.constellation_chan.send(msg) { - warn!("Sending window resize to constellation failed ({}).", e); + warn!("Sending window resize to constellation failed ({:?}).", e); } } @@ -701,7 +701,7 @@ impl<Window: WindowMethods> IOCompositor<Window> { let pipeline_id = PipelineId::from_webrender(result.pipeline); let msg = ConstellationMsg::ForwardEvent(pipeline_id, event_to_send); if let Err(e) = self.constellation_chan.send(msg) { - warn!("Sending event to constellation failed ({}).", e); + warn!("Sending event to constellation failed ({:?}).", e); } } @@ -743,13 +743,13 @@ impl<Window: WindowMethods> IOCompositor<Window> { let pipeline_id = PipelineId::from_webrender(item.pipeline); let msg = ConstellationMsg::ForwardEvent(pipeline_id, event); if let Err(e) = self.constellation_chan.send(msg) { - warn!("Sending event to constellation failed ({}).", e); + warn!("Sending event to constellation failed ({:?}).", e); } if let Some(cursor) = CursorKind::from_u8(item.tag.1 as _).ok() { let msg = ConstellationMsg::SetCursor(cursor); if let Err(e) = self.constellation_chan.send(msg) { - warn!("Sending event to constellation failed ({}).", e); + warn!("Sending event to constellation failed ({:?}).", e); } } } @@ -772,7 +772,7 @@ impl<Window: WindowMethods> IOCompositor<Window> { let pipeline_id = PipelineId::from_webrender(item.pipeline); let msg = ConstellationMsg::ForwardEvent(pipeline_id, event); if let Err(e) = self.constellation_chan.send(msg) { - warn!("Sending event to constellation failed ({}).", e); + warn!("Sending event to constellation failed ({:?}).", e); } } } @@ -1008,7 +1008,7 @@ impl<Window: WindowMethods> IOCompositor<Window> { if animation_callbacks_running { let msg = ConstellationMsg::TickAnimation(pipeline_id, AnimationTickType::Script); if let Err(e) = self.constellation_chan.send(msg) { - warn!("Sending tick to constellation failed ({}).", e); + warn!("Sending tick to constellation failed ({:?}).", e); } } @@ -1017,7 +1017,7 @@ impl<Window: WindowMethods> IOCompositor<Window> { if animations_running { let msg = ConstellationMsg::TickAnimation(pipeline_id, AnimationTickType::Layout); if let Err(e) = self.constellation_chan.send(msg) { - warn!("Sending tick to constellation failed ({}).", e); + warn!("Sending tick to constellation failed ({:?}).", e); } } } @@ -1160,7 +1160,7 @@ impl<Window: WindowMethods> IOCompositor<Window> { // if it's safe to output the image. let msg = ConstellationMsg::IsReadyToSaveImage(pipeline_epochs); if let Err(e) = self.constellation_chan.send(msg) { - warn!("Sending ready to save to constellation failed ({}).", e); + warn!("Sending ready to save to constellation failed ({:?}).", e); } self.ready_to_save_state = ReadyState::WaitingForConstellationReply; Err(NotReadyToPaint::JustNotifiedConstellation) @@ -1288,8 +1288,8 @@ impl<Window: WindowMethods> IOCompositor<Window> { if let Some(pipeline) = self.pipeline(*id) { // and inform the layout thread with the measured paint time. let msg = LayoutControlMsg::PaintMetric(epoch, paint_time); - if let Err(e) = pipeline.layout_chan.send(msg) { - warn!("Sending PaintMetric message to layout failed ({}).", e); + if let Err(e) = pipeline.layout_chan.send(msg) { + warn!("Sending PaintMetric message to layout failed ({:?}).", e); } } } diff --git a/components/compositing/compositor_thread.rs b/components/compositing/compositor_thread.rs index 9ea2f73ab35..c0a0169cdcd 100644 --- a/components/compositing/compositor_thread.rs +++ b/components/compositing/compositor_thread.rs @@ -14,8 +14,8 @@ use net_traits::image::base::Image; use profile_traits::mem; use profile_traits::time; use script_traits::{AnimationState, ConstellationMsg, EventResult}; +use servo_channel::{Receiver, Sender}; use std::fmt::{Debug, Error, Formatter}; -use std::sync::mpsc::{Receiver, Sender}; use style_traits::viewport::ViewportConstraints; use webrender; use webrender_api::{self, DeviceIntPoint, DeviceUintSize}; @@ -28,9 +28,8 @@ pub struct CompositorProxy { impl CompositorProxy { pub fn send(&self, msg: Msg) { - // Send a message and kick the OS event loop awake. if let Err(err) = self.sender.send(msg) { - warn!("Failed to send response ({}).", err); + warn!("Failed to send response ({:?}).", err); } self.event_loop_waker.wake(); } @@ -52,7 +51,7 @@ pub struct CompositorReceiver { impl CompositorReceiver { pub fn try_recv_compositor_msg(&mut self) -> Option<Msg> { - self.receiver.try_recv().ok() + self.receiver.try_recv() } pub fn recv_compositor_msg(&mut self) -> Msg { self.receiver.recv().unwrap() diff --git a/components/compositing/lib.rs b/components/compositing/lib.rs index f53c98baeb4..6b8bfb5aaf7 100644 --- a/components/compositing/lib.rs +++ b/components/compositing/lib.rs @@ -19,6 +19,7 @@ extern crate msg; extern crate net_traits; extern crate profile_traits; extern crate script_traits; +extern crate servo_channel; extern crate servo_config; extern crate servo_geometry; extern crate servo_url; diff --git a/components/constellation/Cargo.toml b/components/constellation/Cargo.toml index ef740e8ee8f..e0c629096f6 100644 --- a/components/constellation/Cargo.toml +++ b/components/constellation/Cargo.toml @@ -23,7 +23,7 @@ embedder_traits = { path = "../embedder_traits" } gfx = {path = "../gfx"} gfx_traits = {path = "../gfx_traits"} hyper = "0.10" -ipc-channel = "0.10" +ipc-channel = "0.11" layout_traits = {path = "../layout_traits"} log = "0.4" metrics = {path = "../metrics"} @@ -33,6 +33,7 @@ net_traits = {path = "../net_traits"} profile_traits = {path = "../profile_traits"} script_traits = {path = "../script_traits"} serde = "1.0" +servo_channel = {path = "../channel"} style_traits = {path = "../style_traits"} servo_config = {path = "../config"} servo_rand = {path = "../rand"} diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs index a08768c06dc..826e0cd972f 100644 --- a/components/constellation/constellation.rs +++ b/components/constellation/constellation.rs @@ -132,6 +132,7 @@ use script_traits::{LogEntry, ScriptToConstellationChan, ServiceWorkerMsg, webdr use script_traits::{SWManagerMsg, ScopeThings, UpdatePipelineIdReason, WebDriverCommandMsg}; use script_traits::{WindowSizeData, WindowSizeType}; use serde::{Deserialize, Serialize}; +use servo_channel::{Receiver, Sender, channel}; use servo_config::opts; use servo_config::prefs::PREFS; use servo_rand::{Rng, SeedableRng, ServoRng, random}; @@ -145,7 +146,6 @@ use std::mem::replace; use std::process; use std::rc::{Rc, Weak}; use std::sync::Arc; -use std::sync::mpsc::{Receiver, Sender, channel}; use std::thread; use style_traits::CSSPixel; use style_traits::cursor::CursorKind; @@ -875,7 +875,6 @@ where } /// Handles loading pages, navigation, and granting access to the compositor - #[allow(unsafe_code)] fn handle_request(&mut self) { enum Request { Script((PipelineId, FromScriptMsg)), @@ -896,25 +895,23 @@ where // produces undefined behaviour, resulting in the destructor // being called. If this happens, there's not much we can do // other than panic. - let request = { - let receiver_from_script = &self.script_receiver; - let receiver_from_compositor = &self.compositor_receiver; - let receiver_from_layout = &self.layout_receiver; - let receiver_from_network_listener = &self.network_listener_receiver; - let receiver_from_swmanager = &self.swmanager_receiver; - select! { - msg = receiver_from_script.recv() => - msg.expect("Unexpected script channel panic in constellation").map(Request::Script), - msg = receiver_from_compositor.recv() => - Ok(Request::Compositor(msg.expect("Unexpected compositor channel panic in constellation"))), - msg = receiver_from_layout.recv() => - msg.expect("Unexpected layout channel panic in constellation").map(Request::Layout), - msg = receiver_from_network_listener.recv() => - Ok(Request::NetworkListener( - msg.expect("Unexpected network listener channel panic in constellation") - )), - msg = receiver_from_swmanager.recv() => - msg.expect("Unexpected panic channel panic in constellation").map(Request::FromSWManager) + let request = select! { + recv(self.script_receiver.select(), msg) => { + msg.expect("Unexpected script channel panic in constellation").map(Request::Script) + } + recv(self.compositor_receiver.select(), msg) => { + Ok(Request::Compositor(msg.expect("Unexpected compositor channel panic in constellation"))) + } + recv(self.layout_receiver.select(), msg) => { + msg.expect("Unexpected layout channel panic in constellation").map(Request::Layout) + } + recv(self.network_listener_receiver.select(), msg) => { + Ok(Request::NetworkListener( + msg.expect("Unexpected network listener channel panic in constellation") + )) + } + recv(self.swmanager_receiver.select(), msg) => { + msg.expect("Unexpected panic channel panic in constellation").map(Request::FromSWManager) } }; @@ -1442,7 +1439,7 @@ where debug!("Exiting devtools."); let msg = DevtoolsControlMsg::FromChrome(ChromeToDevtoolsControlMsg::ServerExitMsg); if let Err(e) = chan.send(msg) { - warn!("Exit devtools failed ({})", e); + warn!("Exit devtools failed ({:?})", e); } } diff --git a/components/constellation/lib.rs b/components/constellation/lib.rs index ab6b8722236..1e0e9ed8ed4 100644 --- a/components/constellation/lib.rs +++ b/components/constellation/lib.rs @@ -4,7 +4,6 @@ #![deny(unsafe_code)] #![cfg_attr(feature = "unstable", feature(conservative_impl_trait))] -#![feature(mpsc_select)] extern crate backtrace; extern crate bluetooth_traits; @@ -32,7 +31,6 @@ extern crate net; extern crate net_traits; extern crate profile_traits; extern crate script_traits; -#[macro_use] extern crate serde; #[macro_use] extern crate servo_channel; diff --git a/components/constellation/network_listener.rs b/components/constellation/network_listener.rs index 823fca4608c..461be7990da 100644 --- a/components/constellation/network_listener.rs +++ b/components/constellation/network_listener.rs @@ -15,7 +15,7 @@ use net_traits::{CoreResourceMsg, FetchChannels, FetchMetadata, FetchResponseMsg use net_traits::{IpcSend, NetworkError, ResourceThreads}; use net_traits::request::{Destination, RequestInit}; use net_traits::response::ResponseInit; -use std::sync::mpsc::Sender; +use servo_channel::Sender; pub struct NetworkListener { res_init: Option<ResponseInit>, diff --git a/components/constellation/pipeline.rs b/components/constellation/pipeline.rs index 62899328ca1..d45129db3c0 100644 --- a/components/constellation/pipeline.rs +++ b/components/constellation/pipeline.rs @@ -28,6 +28,7 @@ use script_traits::{DocumentActivity, InitialScriptState}; use script_traits::{LayoutControlMsg, LayoutMsg, LoadData}; use script_traits::{NewLayoutInfo, SWManagerMsg, SWManagerSenders}; use script_traits::{ScriptThreadFactory, TimerSchedulerMsg, WindowSizeData}; +use servo_channel::Sender; use servo_config::opts::{self, Opts}; use servo_config::prefs::{PREFS, Pref}; use servo_url::ServoUrl; @@ -38,7 +39,6 @@ use std::ffi::OsStr; use std::process; use std::rc::Rc; use std::sync::Arc; -use std::sync::mpsc::Sender; use style_traits::CSSPixel; use style_traits::DevicePixel; use webrender_api; @@ -255,7 +255,7 @@ impl Pipeline { Ok(message) => if let Err(e) = devtools_chan.send(DevtoolsControlMsg::FromScript(message)) { - warn!("Sending to devtools failed ({})", e) + warn!("Sending to devtools failed ({:?})", e) }, }, ), diff --git a/components/constellation/timer_scheduler.rs b/components/constellation/timer_scheduler.rs index 8872204374e..6581c3f0916 100644 --- a/components/constellation/timer_scheduler.rs +++ b/components/constellation/timer_scheduler.rs @@ -4,9 +4,9 @@ use ipc_channel::ipc::{self, IpcSender}; use script_traits::{TimerEvent, TimerEventRequest, TimerSchedulerMsg}; +use servo_channel::base_channel; use std::cmp::{self, Ord}; use std::collections::BinaryHeap; -use servo_channel::base_channel; use std::thread; use std::time::{Duration, Instant}; @@ -69,26 +69,29 @@ impl TimerScheduler { scheduled_events.pop(); } // Look to see if there are any incoming events - match req_receiver.try_recv() { - // If there is an event, add it to the priority queue - Ok(TimerSchedulerMsg::Request(req)) => { - let TimerEventRequest(_, _, _, delay) = req; - let schedule = Instant::now() + Duration::from_millis(delay.get()); - let event = ScheduledEvent { - request: req, - for_time: schedule, - }; - scheduled_events.push(event); + select! { + recv(req_receiver, msg) => match msg { + // If there is an event, add it to the priority queue + Some(TimerSchedulerMsg::Request(req)) => { + let TimerEventRequest(_, _, _, delay) = req; + let schedule = Instant::now() + Duration::from_millis(delay.get()); + let event = ScheduledEvent { + request: req, + for_time: schedule, + }; + scheduled_events.push(event); + }, + // If the channel is closed or we are shutting down, we are done. + Some(TimerSchedulerMsg::Exit) | + None => break, }, // If there is no incoming event, park the thread, // it will either be unparked when a new event arrives, // or by a timeout. - Err(Empty) => match scheduled_events.peek() { + default => match scheduled_events.peek() { None => thread::park(), Some(event) => thread::park_timeout(event.for_time - now), }, - // If the channel is closed or we are shutting down, we are done. - Ok(TimerSchedulerMsg::Exit) | Err(Disconnected) => break, } } // This thread can terminate if the req_ipc_sender is dropped. diff --git a/components/debugger/Cargo.toml b/components/debugger/Cargo.toml index 0f04322c80e..f03fd899332 100644 --- a/components/debugger/Cargo.toml +++ b/components/debugger/Cargo.toml @@ -12,4 +12,5 @@ crate_type = ["rlib"] [dependencies] log = "0.4" +servo_channel = {path = "../channel"} ws = "0.7.3" diff --git a/components/debugger/lib.rs b/components/debugger/lib.rs index 6190ebec89b..938e16906e3 100644 --- a/components/debugger/lib.rs +++ b/components/debugger/lib.rs @@ -4,10 +4,9 @@ #[macro_use] extern crate log; +extern crate servo_channel; extern crate ws; -use std::sync::mpsc; -use std::sync::mpsc::channel; use std::thread; use ws::{Builder, CloseCode, Handler, Handshake}; @@ -15,7 +14,7 @@ enum Message { ShutdownServer, } -pub struct Sender(mpsc::Sender<Message>); +pub struct Sender(servo_channel::Sender<Message>); struct Connection { sender: ws::Sender, @@ -38,7 +37,7 @@ impl Handler for Connection { pub fn start_server(port: u16) -> Sender { debug!("Starting server."); - let (sender, receiver) = channel(); + let (sender, receiver) = servo_channel::channel(); thread::Builder::new() .name("debugger".to_owned()) .spawn(move || { @@ -51,7 +50,7 @@ pub fn start_server(port: u16) -> Sender { .spawn(move || { socket.listen(("127.0.0.1", port)).unwrap(); }).expect("Thread spawning failed"); - while let Ok(message) = receiver.recv() { + while let Some(message) = receiver.recv() { match message { Message::ShutdownServer => { break; diff --git a/components/devtools/Cargo.toml b/components/devtools/Cargo.toml index fb80f609d84..1bcbc1290b2 100644 --- a/components/devtools/Cargo.toml +++ b/components/devtools/Cargo.toml @@ -13,9 +13,10 @@ path = "lib.rs" devtools_traits = {path = "../devtools_traits"} hyper = "0.10" hyper_serde = "0.8" -ipc-channel = "0.10" +ipc-channel = "0.11" log = "0.4" msg = {path = "../msg"} serde = "1.0" serde_json = "1.0" +servo_channel = {path = "../channel"} time = "0.1" diff --git a/components/devtools/lib.rs b/components/devtools/lib.rs index 2e11fa0eda2..8bd34c0a1d0 100644 --- a/components/devtools/lib.rs +++ b/components/devtools/lib.rs @@ -21,6 +21,7 @@ extern crate msg; #[macro_use] extern crate serde; extern crate serde_json; +extern crate servo_channel; extern crate time; use actor::{Actor, ActorRegistry}; @@ -41,13 +42,13 @@ use devtools_traits::{ScriptToDevtoolsControlMsg, WorkerId}; use ipc_channel::ipc::IpcSender; use msg::constellation_msg::PipelineId; use protocol::JsonPacketStream; +use servo_channel::{Receiver, Sender, channel}; use std::borrow::ToOwned; use std::cell::RefCell; use std::collections::HashMap; use std::collections::hash_map::Entry::{Occupied, Vacant}; use std::net::{Shutdown, TcpListener, TcpStream}; use std::sync::{Arc, Mutex}; -use std::sync::mpsc::{Receiver, Sender, channel}; use std::thread; use time::precise_time_ns; @@ -509,7 +510,7 @@ fn run_server( } }).expect("Thread spawning failed"); - while let Ok(msg) = receiver.recv() { + while let Some(msg) = receiver.recv() { match msg { DevtoolsControlMsg::FromChrome(ChromeToDevtoolsControlMsg::AddClient(stream)) => { let actors = actors.clone(); diff --git a/components/devtools_traits/Cargo.toml b/components/devtools_traits/Cargo.toml index 49c7f7ac332..34359dadf41 100644 --- a/components/devtools_traits/Cargo.toml +++ b/components/devtools_traits/Cargo.toml @@ -13,7 +13,7 @@ path = "lib.rs" bitflags = "1.0" hyper = "0.10" hyper_serde = "0.8" -ipc-channel = "0.10" +ipc-channel = "0.11" malloc_size_of = { path = "../malloc_size_of" } malloc_size_of_derive = { path = "../malloc_size_of_derive" } msg = {path = "../msg"} diff --git a/components/embedder_traits/Cargo.toml b/components/embedder_traits/Cargo.toml index eb8bc420db6..da187d7d370 100644 --- a/components/embedder_traits/Cargo.toml +++ b/components/embedder_traits/Cargo.toml @@ -13,11 +13,12 @@ path = "lib.rs" tests = [] [dependencies] -ipc-channel = "0.10" +ipc-channel = "0.11" lazy_static = "1" log = "0.4" msg = {path = "../msg"} serde = "1.0" +servo_channel = {path = "../channel"} servo_url = {path = "../url"} style_traits = {path = "../style_traits"} webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]} diff --git a/components/embedder_traits/lib.rs b/components/embedder_traits/lib.rs index a02eb31a0f4..6bb9281b7d2 100644 --- a/components/embedder_traits/lib.rs +++ b/components/embedder_traits/lib.rs @@ -10,6 +10,7 @@ extern crate log; extern crate msg; #[macro_use] extern crate serde; +extern crate servo_channel; extern crate servo_url; extern crate style_traits; extern crate webrender_api; @@ -18,9 +19,9 @@ pub mod resources; use ipc_channel::ipc::IpcSender; use msg::constellation_msg::{InputMethodType, Key, KeyModifiers, KeyState, TopLevelBrowsingContextId}; +use servo_channel::{Receiver, Sender}; use servo_url::ServoUrl; use std::fmt::{Debug, Error, Formatter}; -use std::sync::mpsc::{Receiver, Sender}; use style_traits::cursor::CursorKind; use webrender_api::{DeviceIntPoint, DeviceUintSize}; @@ -40,7 +41,7 @@ impl EmbedderProxy { pub fn send(&self, msg: (Option<TopLevelBrowsingContextId>, EmbedderMsg)) { // Send a message and kick the OS event loop awake. if let Err(err) = self.sender.send(msg) { - warn!("Failed to send response ({}).", err); + warn!("Failed to send response ({:?}).", err); } self.event_loop_waker.wake(); } @@ -64,7 +65,7 @@ impl EmbedderReceiver { pub fn try_recv_embedder_msg( &mut self, ) -> Option<(Option<TopLevelBrowsingContextId>, EmbedderMsg)> { - self.receiver.try_recv().ok() + self.receiver.try_recv() } pub fn recv_embedder_msg(&mut self) -> (Option<TopLevelBrowsingContextId>, EmbedderMsg) { self.receiver.recv().unwrap() diff --git a/components/gfx/Cargo.toml b/components/gfx/Cargo.toml index a9f7a10c23f..90b1f6f3575 100644 --- a/components/gfx/Cargo.toml +++ b/components/gfx/Cargo.toml @@ -23,7 +23,7 @@ fnv = "1.0" fontsan = {git = "https://github.com/servo/fontsan"} gfx_traits = {path = "../gfx_traits"} harfbuzz-sys = "0.2" -ipc-channel = "0.10" +ipc-channel = "0.11" lazy_static = "1" libc = "0.2" log = "0.4" diff --git a/components/layout/Cargo.toml b/components/layout/Cargo.toml index 1b0e08ab92e..efa63206c4b 100644 --- a/components/layout/Cargo.toml +++ b/components/layout/Cargo.toml @@ -22,7 +22,7 @@ fxhash = "0.2" gfx = {path = "../gfx"} gfx_traits = {path = "../gfx_traits"} html5ever = "0.22" -ipc-channel = "0.10" +ipc-channel = "0.11" libc = "0.2" log = "0.4" malloc_size_of = { path = "../malloc_size_of" } @@ -39,6 +39,7 @@ selectors = { path = "../selectors" } serde = "1.0" servo_arc = {path = "../servo_arc"} servo_atoms = {path = "../atoms"} +servo_channel = {path = "../channel"} servo_geometry = {path = "../geometry"} serde_json = "1.0" servo_config = {path = "../config"} diff --git a/components/layout/animation.rs b/components/layout/animation.rs index d8b305644c0..b42933bb400 100644 --- a/components/layout/animation.rs +++ b/components/layout/animation.rs @@ -13,7 +13,7 @@ use msg::constellation_msg::PipelineId; use opaque_node::OpaqueNodeMethods; use script_traits::{AnimationState, ConstellationControlMsg, LayoutMsg as ConstellationMsg}; use script_traits::UntrustedNodeAddress; -use std::sync::mpsc::Receiver; +use servo_channel::Receiver; use style::animation::{Animation, update_style_for_animation}; use style::dom::TElement; use style::font_metrics::ServoMetricsProvider; @@ -36,7 +36,7 @@ pub fn update_animation_state<E>( E: TElement, { let mut new_running_animations = vec![]; - while let Ok(animation) = new_animations_receiver.try_recv() { + while let Some(animation) = new_animations_receiver.try_recv() { let mut should_push = true; if let Animation::Keyframes(ref node, _, ref name, ref state) = animation { // If the animation was already present in the list for the diff --git a/components/layout/lib.rs b/components/layout/lib.rs index ce47eb72620..3dc289a11fa 100644 --- a/components/layout/lib.rs +++ b/components/layout/lib.rs @@ -36,6 +36,7 @@ extern crate serde; extern crate serde_json; extern crate servo_arc; extern crate servo_atoms; +extern crate servo_channel; extern crate servo_config; extern crate servo_geometry; extern crate servo_url; diff --git a/components/layout_thread/Cargo.toml b/components/layout_thread/Cargo.toml index a17f90e899e..2c76600dbfb 100644 --- a/components/layout_thread/Cargo.toml +++ b/components/layout_thread/Cargo.toml @@ -23,7 +23,7 @@ gfx = {path = "../gfx"} gfx_traits = {path = "../gfx_traits"} histogram = "0.6.8" html5ever = "0.22" -ipc-channel = "0.10" +ipc-channel = "0.11" layout = {path = "../layout"} layout_traits = {path = "../layout_traits"} lazy_static = "1" @@ -46,6 +46,7 @@ serde_json = "1.0" servo_allocator = {path = "../allocator"} servo_arc = {path = "../servo_arc"} servo_atoms = {path = "../atoms"} +servo_channel = {path = "../channel"} servo_config = {path = "../config"} servo_geometry = {path = "../geometry"} servo_url = {path = "../url"} diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs index a193cab566f..3057701f360 100644 --- a/components/layout_thread/lib.rs +++ b/components/layout_thread/lib.rs @@ -5,8 +5,6 @@ //! The layout thread. Performs layout on the DOM, builds display lists and sends them to be //! painted. -#![feature(mpsc_select)] - extern crate app_units; extern crate atomic_refcell; extern crate embedder_traits; @@ -69,7 +67,6 @@ use gfx::font_context; use gfx_traits::{Epoch, node_id_from_scroll_id}; use histogram::Histogram; use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; -use ipc_channel::router::ROUTER; use layout::animation; use layout::construct::ConstructionResult; use layout::context::LayoutContext; @@ -113,6 +110,7 @@ use script_traits::Painter; use selectors::Element; use servo_arc::Arc as ServoArc; use servo_atoms::Atom; +use servo_channel::{Receiver, Sender, channel, route_ipc_receiver_to_new_servo_receiver}; use servo_config::opts; use servo_config::prefs::PREFS; use servo_geometry::MaxRect; @@ -125,7 +123,6 @@ use std::ops::{Deref, DerefMut}; use std::process; use std::sync::{Arc, Mutex, MutexGuard}; use std::sync::atomic::{AtomicUsize, Ordering}; -use std::sync::mpsc::{Receiver, Sender, channel}; use std::thread; use style::animation::Animation; use style::context::{QuirksMode, RegisteredSpeculativePainter, RegisteredSpeculativePainters}; @@ -506,12 +503,12 @@ impl LayoutThread { let (new_animations_sender, new_animations_receiver) = channel(); // Proxy IPC messages from the pipeline to the layout thread. - let pipeline_receiver = ROUTER.route_ipc_receiver_to_new_mpsc_receiver(pipeline_port); + let pipeline_receiver = route_ipc_receiver_to_new_servo_receiver(pipeline_port); // Ask the router to proxy IPC messages from the font cache thread to the layout thread. let (ipc_font_cache_sender, ipc_font_cache_receiver) = ipc::channel().unwrap(); let font_cache_receiver = - ROUTER.route_ipc_receiver_to_new_mpsc_receiver(ipc_font_cache_receiver); + route_ipc_receiver_to_new_servo_receiver(ipc_font_cache_receiver); LayoutThread { id: id, @@ -641,22 +638,10 @@ impl LayoutThread { FromFontCache, } - let request = { - let port_from_script = &self.port; - let port_from_pipeline = &self.pipeline_port; - let port_from_font_cache = &self.font_cache_receiver; - select! { - msg = port_from_pipeline.recv() => { - Request::FromPipeline(msg.unwrap()) - }, - msg = port_from_script.recv() => { - Request::FromScript(msg.unwrap()) - }, - msg = port_from_font_cache.recv() => { - msg.unwrap(); - Request::FromFontCache - } - } + let request = select! { + recv(self.pipeline_port.select(), msg) => Request::FromPipeline(msg.unwrap()), + recv(self.port.select(), msg) => Request::FromScript(msg.unwrap()), + recv(self.font_cache_receiver.select(), msg) => { msg.unwrap(); Request::FromFontCache } }; match request { diff --git a/components/layout_traits/Cargo.toml b/components/layout_traits/Cargo.toml index 38c53836bd9..162c7add7b4 100644 --- a/components/layout_traits/Cargo.toml +++ b/components/layout_traits/Cargo.toml @@ -11,11 +11,12 @@ path = "lib.rs" [dependencies] gfx = {path = "../gfx"} -ipc-channel = "0.10" +ipc-channel = "0.11" metrics = {path = "../metrics"} msg = {path = "../msg"} net_traits = {path = "../net_traits"} profile_traits = {path = "../profile_traits"} script_traits = {path = "../script_traits"} +servo_channel = {path = "../channel"} servo_url = {path = "../url"} webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]} diff --git a/components/layout_traits/lib.rs b/components/layout_traits/lib.rs index 6566065e421..646706e7717 100644 --- a/components/layout_traits/lib.rs +++ b/components/layout_traits/lib.rs @@ -11,6 +11,7 @@ extern crate msg; extern crate net_traits; extern crate profile_traits; extern crate script_traits; +extern crate servo_channel; extern crate servo_url; extern crate webrender_api; @@ -28,9 +29,9 @@ use net_traits::image_cache::ImageCache; use profile_traits::{mem, time}; use script_traits::{ConstellationControlMsg, LayoutControlMsg}; use script_traits::LayoutMsg as ConstellationMsg; +use servo_channel::{Receiver, Sender}; use servo_url::ServoUrl; use std::sync::Arc; -use std::sync::mpsc::{Receiver, Sender}; // A static method creating a layout thread // Here to remove the compositor -> layout dependency diff --git a/components/malloc_size_of/Cargo.toml b/components/malloc_size_of/Cargo.toml index 61798508395..8a401dd012f 100644 --- a/components/malloc_size_of/Cargo.toml +++ b/components/malloc_size_of/Cargo.toml @@ -34,6 +34,7 @@ selectors = { path = "../selectors" } serde = { version = "1.0.27", optional = true } serde_bytes = { version = "0.10", optional = true } servo_arc = { path = "../servo_arc" } +servo_channel = {path = "../channel"} smallbitvec = "2.1.0" smallvec = "0.6" string_cache = { version = "0.7", optional = true } diff --git a/components/malloc_size_of/lib.rs b/components/malloc_size_of/lib.rs index 945ff9418b6..d39d162f6b3 100644 --- a/components/malloc_size_of/lib.rs +++ b/components/malloc_size_of/lib.rs @@ -59,6 +59,7 @@ extern crate serde; #[cfg(feature = "servo")] extern crate serde_bytes; extern crate servo_arc; +extern crate servo_channel; extern crate smallbitvec; extern crate smallvec; #[cfg(feature = "servo")] @@ -1023,7 +1024,7 @@ where // Placeholder for unique case where internals of Sender cannot be measured. // malloc size of is 0 macro complains about type supplied! -impl<T> MallocSizeOf for std::sync::mpsc::Sender<T> { +impl<T> MallocSizeOf for servo_channel::Sender<T> { fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize { 0 } diff --git a/components/metrics/Cargo.toml b/components/metrics/Cargo.toml index 105d95e2715..608d7ffaa0a 100644 --- a/components/metrics/Cargo.toml +++ b/components/metrics/Cargo.toml @@ -11,7 +11,7 @@ path = "lib.rs" [dependencies] gfx_traits = {path = "../gfx_traits"} -ipc-channel = "0.10" +ipc-channel = "0.11" log = "0.4" malloc_size_of = { path = "../malloc_size_of" } malloc_size_of_derive = { path = "../malloc_size_of_derive" } diff --git a/components/net/Cargo.toml b/components/net/Cargo.toml index 21820d71273..aca08703bae 100644 --- a/components/net/Cargo.toml +++ b/components/net/Cargo.toml @@ -23,7 +23,7 @@ hyper = "0.10" hyper_serde = "0.8" hyper-openssl = "0.2.2" immeta = "0.4" -ipc-channel = "0.10" +ipc-channel = "0.11" lazy_static = "1" log = "0.4" malloc_size_of = { path = "../malloc_size_of" } @@ -39,6 +39,7 @@ serde = "1.0" serde_json = "1.0" servo_allocator = {path = "../allocator"} servo_arc = {path = "../servo_arc"} +servo_channel = {path = "../channel"} servo_config = {path = "../config"} servo_url = {path = "../url"} threadpool = "1.0" diff --git a/components/net/fetch/methods.rs b/components/net/fetch/methods.rs index 2ed528e17fb..931a6e778e7 100644 --- a/components/net/fetch/methods.rs +++ b/components/net/fetch/methods.rs @@ -21,6 +21,7 @@ use net_traits::{FetchTaskTarget, NetworkError, ReferrerPolicy}; use net_traits::request::{CredentialsMode, Destination, Referrer, Request, RequestMode}; use net_traits::request::{ResponseTainting, Origin, Window}; use net_traits::response::{Response, ResponseBody, ResponseType}; +use servo_channel::{channel, Sender, Receiver}; use servo_url::ServoUrl; use std::borrow::Cow; use std::fmt; @@ -30,7 +31,6 @@ use std::mem; use std::str; use std::sync::{Arc, Mutex}; use std::sync::atomic::Ordering; -use std::sync::mpsc::{Sender, Receiver, channel}; use std::thread; use subresource_integrity::is_response_integrity_valid; diff --git a/components/net/http_cache.rs b/components/net/http_cache.rs index 601a4f6cc65..1fcafc92952 100644 --- a/components/net/http_cache.rs +++ b/components/net/http_cache.rs @@ -20,13 +20,13 @@ use net_traits::{Metadata, FetchMetadata}; use net_traits::request::Request; use net_traits::response::{HttpsState, Response, ResponseBody}; use servo_arc::Arc; +use servo_channel::{Sender, channel}; use servo_config::prefs::PREFS; use servo_url::ServoUrl; use std::collections::HashMap; use std::str; use std::sync::Mutex; use std::sync::atomic::{AtomicBool, Ordering}; -use std::sync::mpsc::{channel, Sender}; use time; use time::{Duration, Tm}; diff --git a/components/net/http_loader.rs b/components/net/http_loader.rs index e602c432fd8..fe85fc5a6f7 100644 --- a/components/net/http_loader.rs +++ b/components/net/http_loader.rs @@ -39,6 +39,7 @@ use net_traits::request::{RedirectMode, Referrer, Request, RequestMode}; use net_traits::request::{ResponseTainting, ServiceWorkersMode}; use net_traits::response::{HttpsState, Response, ResponseBody, ResponseType}; use resource_thread::AuthCache; +use servo_channel::{channel, Sender}; use servo_url::{ImmutableOrigin, ServoUrl}; use std::collections::{HashMap, HashSet}; use std::error::Error; @@ -48,7 +49,6 @@ use std::mem; use std::ops::Deref; use std::str::FromStr; use std::sync::RwLock; -use std::sync::mpsc::{channel, Sender}; use std::thread; use time; use time::Tm; diff --git a/components/net/lib.rs b/components/net/lib.rs index 928d7ae191a..ab5c3bc74a2 100644 --- a/components/net/lib.rs +++ b/components/net/lib.rs @@ -33,6 +33,7 @@ extern crate profile_traits; extern crate serde_json; extern crate servo_allocator; extern crate servo_arc; +extern crate servo_channel; extern crate servo_config; extern crate servo_url; extern crate time; diff --git a/components/net/resource_thread.rs b/components/net/resource_thread.rs index ffcdccebfe9..cddf0cb0a0b 100644 --- a/components/net/resource_thread.rs +++ b/components/net/resource_thread.rs @@ -32,6 +32,7 @@ use profile_traits::time::ProfilerChan; use serde::{Deserialize, Serialize}; use serde_json; use servo_allocator; +use servo_channel::Sender; use servo_config::opts; use servo_url::ServoUrl; use std::borrow::{Cow, ToOwned}; @@ -42,7 +43,6 @@ use std::io::prelude::*; use std::ops::Deref; use std::path::{Path, PathBuf}; use std::sync::{Arc, Mutex, RwLock}; -use std::sync::mpsc::Sender; use std::thread; use storage_thread::StorageThreadFactory; use websocket_loader; diff --git a/components/net/tests/fetch.rs b/components/net/tests/fetch.rs index e71882de3e0..2e33727e37f 100644 --- a/components/net/tests/fetch.rs +++ b/components/net/tests/fetch.rs @@ -3,7 +3,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use {DEFAULT_USER_AGENT, new_fetch_context, create_embedder_proxy, fetch, make_server}; -use devtools_traits::DevtoolsControlMsg; use devtools_traits::HttpRequest as DevtoolsHttpRequest; use devtools_traits::HttpResponse as DevtoolsHttpResponse; use fetch_with_context; @@ -34,13 +33,13 @@ use net_traits::NetworkError; use net_traits::ReferrerPolicy; use net_traits::request::{Destination, Origin, RedirectMode, Referrer, Request, RequestMode}; use net_traits::response::{CacheState, Response, ResponseBody, ResponseType}; +use servo_channel::{channel, Sender}; use servo_url::{ImmutableOrigin, ServoUrl}; use std::fs::File; use std::io::Read; use std::path::Path; use std::sync::{Arc, Mutex}; use std::sync::atomic::{AtomicUsize, Ordering}; -use std::sync::mpsc::{Sender, channel}; use time::{self, Duration}; use unicase::UniCase; @@ -774,17 +773,17 @@ fn test_fetch_redirect_updates_method() { assert_eq!(rx.recv().unwrap(), true); assert_eq!(rx.recv().unwrap(), true); // make sure the test doesn't send more data than expected - assert_eq!(rx.try_recv().is_err(), true); + assert_eq!(rx.try_recv().is_none(), true); test_fetch_redirect_updates_method_runner(tx.clone(), StatusCode::Found, Method::Post); assert_eq!(rx.recv().unwrap(), true); assert_eq!(rx.recv().unwrap(), true); - assert_eq!(rx.try_recv().is_err(), true); + assert_eq!(rx.try_recv().is_none(), true); test_fetch_redirect_updates_method_runner(tx.clone(), StatusCode::SeeOther, Method::Get); assert_eq!(rx.recv().unwrap(), true); assert_eq!(rx.recv().unwrap(), true); - assert_eq!(rx.try_recv().is_err(), true); + assert_eq!(rx.try_recv().is_none(), true); let extension = Method::Extension("FOO".to_owned()); @@ -792,18 +791,18 @@ fn test_fetch_redirect_updates_method() { assert_eq!(rx.recv().unwrap(), true); // for MovedPermanently and Found, Method should only be changed if it was Post assert_eq!(rx.recv().unwrap(), false); - assert_eq!(rx.try_recv().is_err(), true); + assert_eq!(rx.try_recv().is_none(), true); test_fetch_redirect_updates_method_runner(tx.clone(), StatusCode::Found, extension.clone()); assert_eq!(rx.recv().unwrap(), true); assert_eq!(rx.recv().unwrap(), false); - assert_eq!(rx.try_recv().is_err(), true); + assert_eq!(rx.try_recv().is_none(), true); test_fetch_redirect_updates_method_runner(tx.clone(), StatusCode::SeeOther, extension.clone()); assert_eq!(rx.recv().unwrap(), true); // for SeeOther, Method should always be changed, so this should be true assert_eq!(rx.recv().unwrap(), true); - assert_eq!(rx.try_recv().is_err(), true); + assert_eq!(rx.try_recv().is_none(), true); } fn response_is_done(response: &Response) -> bool { @@ -912,7 +911,7 @@ fn test_fetch_with_devtools() { let mut request = Request::new(url.clone(), Some(origin), Some(TEST_PIPELINE_ID)); request.referrer = Referrer::NoReferrer; - let (devtools_chan, devtools_port) = channel::<DevtoolsControlMsg>(); + let (devtools_chan, devtools_port) = channel(); let _ = fetch(&mut request, Some(devtools_chan)); let _ = server.close(); diff --git a/components/net/tests/http_loader.rs b/components/net/tests/http_loader.rs index 46964158b21..96c424469d1 100644 --- a/components/net/tests/http_loader.rs +++ b/components/net/tests/http_loader.rs @@ -30,13 +30,13 @@ use net_traits::{CookieSource, NetworkError}; use net_traits::request::{Request, RequestInit, RequestMode, CredentialsMode, Destination}; use net_traits::response::ResponseBody; use new_fetch_context; +use servo_channel::{channel, Receiver}; use servo_url::{ServoUrl, ImmutableOrigin}; use std::collections::HashMap; use std::io::{Read, Write}; use std::str::FromStr; -use std::sync::{Arc, Mutex, RwLock, mpsc}; +use std::sync::{Arc, Mutex, RwLock}; use std::sync::atomic::{AtomicBool, Ordering}; -use std::sync::mpsc::Receiver; fn mock_origin() -> ImmutableOrigin { ServoUrl::parse("http://servo.org").unwrap().origin() @@ -213,7 +213,7 @@ fn test_request_and_response_data_with_network_messages() { pipeline_id: Some(TEST_PIPELINE_ID), .. RequestInit::default() }); - let (devtools_chan, devtools_port) = mpsc::channel(); + let (devtools_chan, devtools_port) = channel(); let response = fetch(&mut request, Some(devtools_chan)); assert!(response.internal_response.unwrap().status.unwrap().is_success()); @@ -300,14 +300,14 @@ fn test_request_and_response_message_from_devtool_without_pipeline_id() { pipeline_id: None, .. RequestInit::default() }); - let (devtools_chan, devtools_port) = mpsc::channel(); + let (devtools_chan, devtools_port) = channel(); let response = fetch(&mut request, Some(devtools_chan)); assert!(response.internal_response.unwrap().status.unwrap().is_success()); let _ = server.close(); // notification received from devtools - assert!(devtools_port.try_recv().is_err()); + assert!(devtools_port.try_recv().is_none()); } #[test] @@ -334,7 +334,7 @@ fn test_redirected_request_to_devtools() { pipeline_id: Some(TEST_PIPELINE_ID), .. RequestInit::default() }); - let (devtools_chan, devtools_port) = mpsc::channel(); + let (devtools_chan, devtools_port) = channel(); fetch(&mut request, Some(devtools_chan)); let _ = pre_server.close(); diff --git a/components/net/tests/main.rs b/components/net/tests/main.rs index 1a7d5c462a5..aeddb5105d1 100644 --- a/components/net/tests/main.rs +++ b/components/net/tests/main.rs @@ -16,6 +16,7 @@ extern crate msg; extern crate net; extern crate net_traits; extern crate profile_traits; +extern crate servo_channel; extern crate servo_config; extern crate servo_url; extern crate time; @@ -46,9 +47,9 @@ use net::test::HttpState; use net_traits::FetchTaskTarget; use net_traits::request::Request; use net_traits::response::Response; +use servo_channel::{channel, Sender}; use servo_url::ServoUrl; use std::sync::{Arc, Mutex}; -use std::sync::mpsc::{Sender, channel}; const DEFAULT_USER_AGENT: &'static str = "Such Browser. Very Layout. Wow."; diff --git a/components/net_traits/Cargo.toml b/components/net_traits/Cargo.toml index 613bf5fb704..9ae5042be69 100644 --- a/components/net_traits/Cargo.toml +++ b/components/net_traits/Cargo.toml @@ -17,7 +17,7 @@ embedder_traits = { path = "../embedder_traits" } hyper = "0.10" hyper_serde = "0.8" image = "0.19" -ipc-channel = "0.10" +ipc-channel = "0.11" lazy_static = "1" log = "0.4" malloc_size_of = { path = "../malloc_size_of" } diff --git a/components/profile/Cargo.toml b/components/profile/Cargo.toml index a27ee87ee6b..7b9d79a7a8f 100644 --- a/components/profile/Cargo.toml +++ b/components/profile/Cargo.toml @@ -15,7 +15,7 @@ unstable = ["jemalloc-sys"] [dependencies] profile_traits = {path = "../profile_traits"} influent = "0.4" -ipc-channel = "0.10" +ipc-channel = "0.11" heartbeats-simple = "0.4" log = "0.4" serde = "1.0" diff --git a/components/profile_traits/Cargo.toml b/components/profile_traits/Cargo.toml index 4bf33b5d79f..ca9ce8aece6 100644 --- a/components/profile_traits/Cargo.toml +++ b/components/profile_traits/Cargo.toml @@ -16,9 +16,10 @@ energy-profiling = ["energymon", "energy-monitor"] bincode = "1" energy-monitor = {version = "0.2.0", optional = true} energymon = {git = "https://github.com/energymon/energymon-rust.git", optional = true} -ipc-channel = "0.10" +ipc-channel = "0.11" log = "0.4" serde = "1.0" +servo_channel = {path = "../channel"} servo_config = {path = "../config"} signpost = {git = "https://github.com/pcwalton/signpost.git"} time = "0.1.12" diff --git a/components/profile_traits/lib.rs b/components/profile_traits/lib.rs index e70d0b7ac40..017d35b24c1 100644 --- a/components/profile_traits/lib.rs +++ b/components/profile_traits/lib.rs @@ -14,6 +14,7 @@ extern crate ipc_channel; extern crate log; #[macro_use] extern crate serde; +extern crate servo_channel; extern crate servo_config; extern crate signpost; diff --git a/components/profile_traits/mem.rs b/components/profile_traits/mem.rs index 8e4d756884b..b40d8a85586 100644 --- a/components/profile_traits/mem.rs +++ b/components/profile_traits/mem.rs @@ -9,8 +9,8 @@ use ipc_channel::ipc::{self, IpcSender}; use ipc_channel::router::ROUTER; use serde; +use servo_channel::Sender; use std::marker::Send; -use std::sync::mpsc::Sender; /// A trait to abstract away the various kinds of message senders we use. pub trait OpaqueSender<T> { @@ -22,7 +22,7 @@ impl<T> OpaqueSender<T> for Sender<T> { fn send(&self, message: T) { if let Err(e) = Sender::send(self, message) { warn!( - "Error communicating with the target thread from the profiler: {}", + "Error communicating with the target thread from the profiler: {:?}", e ); } diff --git a/components/script/Cargo.toml b/components/script/Cargo.toml index 1a475189a31..ad69761ec51 100644 --- a/components/script/Cargo.toml +++ b/components/script/Cargo.toml @@ -53,7 +53,7 @@ html5ever = "0.22" hyper = "0.10" hyper_serde = "0.8" image = "0.19" -ipc-channel = "0.10" +ipc-channel = "0.11" itertools = "0.7.6" jstraceable_derive = {path = "../jstraceable_derive"} lazy_static = "1" @@ -85,6 +85,7 @@ serde_bytes = "0.10" servo_allocator = {path = "../allocator"} servo_arc = {path = "../servo_arc"} servo_atoms = {path = "../atoms"} +servo_channel = {path = "../channel"} servo_config = {path = "../config"} servo_geometry = {path = "../geometry" } servo-media = {git = "https://github.com/servo/media"} diff --git a/components/script/dom/abstractworkerglobalscope.rs b/components/script/dom/abstractworkerglobalscope.rs index 45c594dbaee..e3e6fbcf813 100644 --- a/components/script/dom/abstractworkerglobalscope.rs +++ b/components/script/dom/abstractworkerglobalscope.rs @@ -11,7 +11,7 @@ use dom::globalscope::GlobalScope; use dom::worker::TrustedWorkerAddress; use dom::workerglobalscope::WorkerGlobalScope; use script_runtime::{ScriptChan, CommonScriptMsg, ScriptPort}; -use std::sync::mpsc::{Receiver, Select, Sender}; +use servo_channel::{Receiver, Sender}; use task_queue::{QueuedTaskConversion, TaskQueue}; /// A ScriptChan that can be cloned freely and will silently send a TrustedWorkerAddress with @@ -65,9 +65,9 @@ impl ScriptChan for WorkerThreadWorkerChan { impl ScriptPort for Receiver<DedicatedWorkerScriptMsg> { fn recv(&self) -> Result<CommonScriptMsg, ()> { let common_msg = match self.recv() { - Ok(DedicatedWorkerScriptMsg::CommonWorker(_worker, common_msg)) => common_msg, - Err(_) => return Err(()), - Ok(DedicatedWorkerScriptMsg::WakeUp) => panic!("unexpected worker event message!") + Some(DedicatedWorkerScriptMsg::CommonWorker(_worker, common_msg)) => common_msg, + None => return Err(()), + Some(DedicatedWorkerScriptMsg::WakeUp) => panic!("unexpected worker event message!") }; match common_msg { WorkerScriptMsg::Common(script_msg) => Ok(script_msg), @@ -89,7 +89,6 @@ pub trait WorkerEventLoopMethods { fn from_devtools_msg(&self, msg: DevtoolScriptControlMsg) -> Self::Event; } -#[allow(unsafe_code)] // https://html.spec.whatwg.org/multipage/#worker-event-loop pub fn run_worker_event_loop<T, TimerMsg, WorkerMsg, Event>(worker_scope: &T, worker: Option<&TrustedWorkerAddress>) @@ -101,31 +100,18 @@ where + DomObject { let scope = worker_scope.upcast::<WorkerGlobalScope>(); let timer_event_port = worker_scope.timer_event_port(); - let devtools_port = scope.from_devtools_receiver(); + let devtools_port = match scope.from_devtools_sender() { + Some(_) => Some(scope.from_devtools_receiver().select()), + None => None, + }; let task_queue = worker_scope.task_queue(); - let sel = Select::new(); - let mut worker_handle = sel.handle(task_queue.select()); - let mut timer_event_handle = sel.handle(timer_event_port); - let mut devtools_handle = sel.handle(devtools_port); - unsafe { - worker_handle.add(); - timer_event_handle.add(); - if scope.from_devtools_sender().is_some() { - devtools_handle.add(); - } - } - let ret = sel.wait(); - let event = { - if ret == worker_handle.id() { - task_queue.take_tasks(); + let event = select! { + recv(task_queue.select(), msg) => { + task_queue.take_tasks(msg.unwrap()); worker_scope.from_worker_msg(task_queue.recv().unwrap()) - } else if ret == timer_event_handle.id() { - worker_scope.from_timer_msg(timer_event_port.recv().unwrap()) - } else if ret == devtools_handle.id() { - worker_scope.from_devtools_msg(devtools_port.recv().unwrap()) - } else { - panic!("unexpected select result!") - } + }, + recv(timer_event_port.select(), msg) => worker_scope.from_timer_msg(msg.unwrap()), + recv(devtools_port, msg) => worker_scope.from_devtools_msg(msg.unwrap()), }; let mut sequential = vec![]; sequential.push(event); @@ -138,14 +124,14 @@ where // Batch all events that are ready. // The task queue will throttle non-priority tasks if necessary. match task_queue.try_recv() { - Err(_) => match timer_event_port.try_recv() { - Err(_) => match devtools_port.try_recv() { - Err(_) => break, - Ok(ev) => sequential.push(worker_scope.from_devtools_msg(ev)), + None => match timer_event_port.try_recv() { + None => match devtools_port.and_then(|port| port.try_recv()) { + None => break, + Some(ev) => sequential.push(worker_scope.from_devtools_msg(ev)), }, - Ok(ev) => sequential.push(worker_scope.from_timer_msg(ev)), + Some(ev) => sequential.push(worker_scope.from_timer_msg(ev)), }, - Ok(ev) => sequential.push(worker_scope.from_worker_msg(ev)), + Some(ev) => sequential.push(worker_scope.from_worker_msg(ev)), } } // Step 3 diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs index 41d1231a580..33cd3e02b55 100644 --- a/components/script/dom/bindings/trace.rs +++ b/components/script/dom/bindings/trace.rs @@ -88,6 +88,7 @@ use selectors::matching::ElementSelectorFlags; use serde::{Deserialize, Serialize}; use servo_arc::Arc as ServoArc; use servo_atoms::Atom; +use servo_channel::{Receiver, Sender}; use servo_media::Backend; use servo_media::audio::buffer_source_node::AudioBuffer; use servo_media::audio::context::AudioContext; @@ -104,7 +105,6 @@ use std::path::PathBuf; use std::rc::Rc; use std::sync::Arc; use std::sync::atomic::{AtomicBool, AtomicUsize}; -use std::sync::mpsc::{Receiver, Sender}; use std::time::{SystemTime, Instant}; use style::attr::{AttrIdentifier, AttrValue, LengthOrPercentageOrAuto}; use style::context::QuirksMode; diff --git a/components/script/dom/dedicatedworkerglobalscope.rs b/components/script/dom/dedicatedworkerglobalscope.rs index c582177f42e..791190e0fd2 100644 --- a/components/script/dom/dedicatedworkerglobalscope.rs +++ b/components/script/dom/dedicatedworkerglobalscope.rs @@ -36,12 +36,12 @@ use net_traits::request::{CredentialsMode, Destination, RequestInit}; use script_runtime::{CommonScriptMsg, ScriptChan, ScriptPort, new_rt_and_cx, Runtime}; use script_runtime::ScriptThreadEventCategory::WorkerEvent; use script_traits::{TimerEvent, TimerSource, WorkerGlobalScopeInit, WorkerScriptLoadOrigin}; +use servo_channel::{channel, route_ipc_receiver_to_new_servo_sender, Sender, Receiver}; use servo_rand::random; use servo_url::ServoUrl; use std::mem::replace; use std::sync::Arc; use std::sync::atomic::AtomicBool; -use std::sync::mpsc::{Receiver, Sender, channel}; use std::thread; use style::thread_state::{self, ThreadState}; use task_queue::{QueuedTask, QueuedTaskConversion, TaskQueue}; @@ -313,7 +313,7 @@ impl DedicatedWorkerGlobalScope { let runtime = unsafe { new_rt_and_cx() }; let (devtools_mpsc_chan, devtools_mpsc_port) = channel(); - ROUTER.route_ipc_receiver_to_mpsc_sender(from_devtools_receiver, devtools_mpsc_chan); + route_ipc_receiver_to_new_servo_sender(from_devtools_receiver, devtools_mpsc_chan); let (timer_tx, timer_rx) = channel(); let (timer_ipc_chan, timer_ipc_port) = ipc::channel().unwrap(); diff --git a/components/script/dom/paintworkletglobalscope.rs b/components/script/dom/paintworkletglobalscope.rs index bf07610719f..352eae0ed0e 100644 --- a/components/script/dom/paintworkletglobalscope.rs +++ b/components/script/dom/paintworkletglobalscope.rs @@ -60,8 +60,6 @@ use std::ptr::null_mut; use std::rc::Rc; use std::sync::Arc; use std::sync::Mutex; -use std::sync::mpsc; -use std::sync::mpsc::Sender; use std::thread; use std::time::Duration; use style_traits::CSSPixel; @@ -352,7 +350,7 @@ impl PaintWorkletGlobalScope { arguments: Vec<String>) -> Result<DrawAPaintImageResult, PaintWorkletError> { let name = self.name.clone(); - let (sender, receiver) = mpsc::channel(); + let (sender, receiver) = channel(); let task = PaintWorkletTask::DrawAPaintImage(name, size, device_pixel_ratio, diff --git a/components/script/dom/serviceworkerglobalscope.rs b/components/script/dom/serviceworkerglobalscope.rs index 50080f9925b..3781ac3be69 100644 --- a/components/script/dom/serviceworkerglobalscope.rs +++ b/components/script/dom/serviceworkerglobalscope.rs @@ -22,17 +22,16 @@ use dom::worker::TrustedWorkerAddress; use dom::workerglobalscope::WorkerGlobalScope; use dom_struct::dom_struct; use ipc_channel::ipc::{self, IpcSender, IpcReceiver}; -use ipc_channel::router::ROUTER; use js::jsapi::{JSAutoCompartment, JSContext, JS_AddInterruptCallback}; use js::jsval::UndefinedValue; use net_traits::{load_whole_resource, IpcSend, CustomResponseMediator}; use net_traits::request::{CredentialsMode, Destination, RequestInit}; use script_runtime::{CommonScriptMsg, ScriptChan, new_rt_and_cx, Runtime}; use script_traits::{TimerEvent, WorkerGlobalScopeInit, ScopeThings, ServiceWorkerMsg, WorkerScriptLoadOrigin}; +use servo_channel::{channel, route_ipc_receiver_to_new_servo_sender, Receiver, Sender}; use servo_config::prefs::PREFS; use servo_rand::random; use servo_url::ServoUrl; -use std::sync::mpsc::{Receiver, Sender, channel}; use std::thread; use std::time::Duration; use style::thread_state::{self, ThreadState}; @@ -272,7 +271,7 @@ impl ServiceWorkerGlobalScope { let runtime = unsafe { new_rt_and_cx() }; let (devtools_mpsc_chan, devtools_mpsc_port) = channel(); - ROUTER.route_ipc_receiver_to_mpsc_sender(devtools_receiver, devtools_mpsc_chan); + route_ipc_receiver_to_new_servo_sender(devtools_receiver, devtools_mpsc_chan); // TODO XXXcreativcoder use this timer_ipc_port, when we have a service worker instance here let (timer_ipc_chan, _timer_ipc_port) = ipc::channel().unwrap(); let (timer_chan, timer_port) = channel(); diff --git a/components/script/dom/servoparser/async_html.rs b/components/script/dom/servoparser/async_html.rs index 7a1319dc31d..5fe911deb0b 100644 --- a/components/script/dom/servoparser/async_html.rs +++ b/components/script/dom/servoparser/async_html.rs @@ -27,12 +27,12 @@ use html5ever::tendril::fmt::UTF8; use html5ever::tokenizer::{Tokenizer as HtmlTokenizer, TokenizerOpts, TokenizerResult}; use html5ever::tree_builder::{ElementFlags, NodeOrText as HtmlNodeOrText, NextParserState, QuirksMode, TreeSink}; use html5ever::tree_builder::{TreeBuilder, TreeBuilderOpts}; +use servo_channel::{channel, Receiver, Sender}; use servo_url::ServoUrl; use std::borrow::Cow; use std::cell::Cell; use std::collections::HashMap; use std::collections::vec_deque::VecDeque; -use std::sync::mpsc::{channel, Receiver, Sender}; use std::thread; use style::context::QuirksMode as ServoQuirksMode; diff --git a/components/script/dom/testworkletglobalscope.rs b/components/script/dom/testworkletglobalscope.rs index 22be6a4765f..a31159de215 100644 --- a/components/script/dom/testworkletglobalscope.rs +++ b/components/script/dom/testworkletglobalscope.rs @@ -13,9 +13,9 @@ use dom::workletglobalscope::WorkletGlobalScopeInit; use dom_struct::dom_struct; use js::rust::Runtime; use msg::constellation_msg::PipelineId; +use servo_channel::Sender; use servo_url::ServoUrl; use std::collections::HashMap; -use std::sync::mpsc::Sender; // check-tidy: no specs after this line diff --git a/components/script/dom/vrdisplay.rs b/components/script/dom/vrdisplay.rs index 397ec725a4d..d44d9d0fa22 100644 --- a/components/script/dom/vrdisplay.rs +++ b/components/script/dom/vrdisplay.rs @@ -36,11 +36,11 @@ use profile_traits::ipc; use script_runtime::CommonScriptMsg; use script_runtime::ScriptThreadEventCategory::WebVREvent; use serde_bytes::ByteBuf; +use servo_channel::{channel, Sender}; use std::cell::Cell; use std::mem; use std::ops::Deref; use std::rc::Rc; -use std::sync::mpsc; use std::thread; use task_source::TaskSourceName; use webvr_traits::{WebVRDisplayData, WebVRDisplayEvent, WebVRFrameData, WebVRLayer, WebVRMsg}; @@ -505,7 +505,7 @@ impl VRDisplay { // while the render thread is syncing the VRFrameData to be used for the current frame. // This thread runs until the user calls ExitPresent, the tab is closed or some unexpected error happened. thread::Builder::new().name("WebVR_RAF".into()).spawn(move || { - let (raf_sender, raf_receiver) = mpsc::channel(); + let (raf_sender, raf_receiver) = channel(); let mut near = near_init; let mut far = far_init; @@ -581,7 +581,7 @@ impl VRDisplay { self.frame_data_status.set(status); } - fn handle_raf(&self, end_sender: &mpsc::Sender<Result<(f64, f64), ()>>) { + fn handle_raf(&self, end_sender: &Sender<Result<(f64, f64), ()>>) { self.frame_data_status.set(VRFrameDataStatus::Waiting); self.running_display_raf.set(true); diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index 052f121fb2a..65630e126a5 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -94,6 +94,7 @@ use script_traits::{TimerSchedulerMsg, UntrustedNodeAddress, WindowSizeData, Win use script_traits::webdriver_msg::{WebDriverJSError, WebDriverJSResult}; use selectors::attr::CaseSensitivity; use servo_arc; +use servo_channel::{channel, Sender}; use servo_config::opts; use servo_geometry::{f32_rect_to_au_rect, MaxRect}; use servo_url::{Host, MutableOrigin, ImmutableOrigin, ServoUrl}; @@ -109,8 +110,6 @@ use std::mem; use std::rc::Rc; use std::sync::{Arc, Mutex}; use std::sync::atomic::{AtomicBool, Ordering}; -use std::sync::mpsc::{Sender, channel}; -use std::sync::mpsc::TryRecvError::{Disconnected, Empty}; use style::error_reporting::ParseErrorReporter; use style::media_queries; use style::parser::ParserContext as CssParserContext; @@ -1376,15 +1375,16 @@ impl Window { debug!("script: layout forked"); - let complete = match join_port.try_recv() { - Err(Empty) => { + let complete = select! { + recv(join_port.select(), msg) => if let Some(reflow_complete) = msg { + reflow_complete + } else { + panic!("Layout thread failed while script was waiting for a result."); + }, + default => { info!("script: waiting on layout"); join_port.recv().unwrap() } - Ok(reflow_complete) => reflow_complete, - Err(Disconnected) => { - panic!("Layout thread failed while script was waiting for a result."); - } }; debug!("script: layout joined"); diff --git a/components/script/dom/worker.rs b/components/script/dom/worker.rs index 653a2fa141c..e5a1bfed223 100644 --- a/components/script/dom/worker.rs +++ b/components/script/dom/worker.rs @@ -25,10 +25,10 @@ use js::jsapi::{JSAutoCompartment, JSContext, JS_RequestInterruptCallback}; use js::jsval::UndefinedValue; use js::rust::HandleValue; use script_traits::WorkerScriptLoadOrigin; +use servo_channel::{channel, Sender}; use std::cell::Cell; use std::sync::Arc; use std::sync::atomic::{AtomicBool, Ordering}; -use std::sync::mpsc::{Sender, channel}; use task::TaskOnce; pub type TrustedWorkerAddress = Trusted<Worker>; diff --git a/components/script/dom/workerglobalscope.rs b/components/script/dom/workerglobalscope.rs index ac372c5fe98..da1f0ba7d36 100644 --- a/components/script/dom/workerglobalscope.rs +++ b/components/script/dom/workerglobalscope.rs @@ -36,12 +36,12 @@ use net_traits::request::{CredentialsMode, Destination, RequestInit as NetReques use script_runtime::{CommonScriptMsg, ScriptChan, ScriptPort, get_reports, Runtime}; use script_traits::{TimerEvent, TimerEventId}; use script_traits::WorkerGlobalScopeInit; +use servo_channel::Receiver; use servo_url::{MutableOrigin, ServoUrl}; use std::default::Default; use std::rc::Rc; use std::sync::Arc; use std::sync::atomic::{AtomicBool, Ordering}; -use std::sync::mpsc::Receiver; use task::TaskCanceller; use task_source::file_reading::FileReadingTaskSource; use task_source::networking::NetworkingTaskSource; diff --git a/components/script/dom/worklet.rs b/components/script/dom/worklet.rs index d1b7ba9c44a..498cce10680 100644 --- a/components/script/dom/worklet.rs +++ b/components/script/dom/worklet.rs @@ -48,6 +48,7 @@ use script_runtime::Runtime; use script_runtime::ScriptThreadEventCategory; use script_runtime::new_rt_and_cx; use script_thread::{MainThreadScriptMsg, ScriptThread}; +use servo_channel::{channel, Sender, Receiver}; use servo_rand; use servo_url::ImmutableOrigin; use servo_url::ServoUrl; @@ -58,9 +59,6 @@ use std::rc::Rc; use std::sync::Arc; use std::sync::atomic::AtomicIsize; use std::sync::atomic::Ordering; -use std::sync::mpsc; -use std::sync::mpsc::Receiver; -use std::sync::mpsc::Sender; use std::thread; use style::thread_state::{self, ThreadState}; use swapper::Swapper; @@ -309,7 +307,7 @@ impl WorkletThreadPool { /// For testing. pub fn test_worklet_lookup(&self, id: WorkletId, key: String) -> Option<String> { - let (sender, receiver) = mpsc::channel(); + let (sender, receiver) = channel(); let msg = WorkletData::Task(id, WorkletTask::Test(TestWorkletTask::Lookup(key, sender))); let _ = self.primary_sender.send(msg); receiver.recv().expect("Test worklet has died?") @@ -355,7 +353,7 @@ struct WorkletThreadRole { impl WorkletThreadRole { fn new(is_hot_backup: bool, is_cold_backup: bool) -> WorkletThreadRole { - let (sender, receiver) = mpsc::channel(); + let (sender, receiver) = channel(); WorkletThreadRole { sender: sender, receiver: receiver, @@ -419,7 +417,7 @@ impl WorkletThread { #[allow(unsafe_code)] #[allow(unrooted_must_root)] fn spawn(role: WorkletThreadRole, init: WorkletThreadInit) -> Sender<WorkletControl> { - let (control_sender, control_receiver) = mpsc::channel(); + let (control_sender, control_receiver) = channel(); // TODO: name this thread thread::spawn(move || { // TODO: add a new IN_WORKLET thread state? @@ -488,12 +486,12 @@ impl WorkletThread { if let Some(control) = self.control_buffer.take() { self.process_control(control); } - while let Ok(control) = self.control_receiver.try_recv() { + while let Some(control) = self.control_receiver.try_recv() { self.process_control(control); } self.gc(); } else if self.control_buffer.is_none() { - if let Ok(control) = self.control_receiver.try_recv() { + if let Some(control) = self.control_receiver.try_recv() { self.control_buffer = Some(control); let msg = WorkletData::StartSwapRoles(self.role.sender.clone()); let _ = self.cold_backup_sender.send(msg); diff --git a/components/script/dom/workletglobalscope.rs b/components/script/dom/workletglobalscope.rs index 653c8e6468e..6a3dc033aad 100644 --- a/components/script/dom/workletglobalscope.rs +++ b/components/script/dom/workletglobalscope.rs @@ -26,11 +26,11 @@ use script_thread::MainThreadScriptMsg; use script_traits::{Painter, ScriptMsg}; use script_traits::{ScriptToConstellationChan, TimerSchedulerMsg}; use servo_atoms::Atom; +use servo_channel::Sender; use servo_url::ImmutableOrigin; use servo_url::MutableOrigin; use servo_url::ServoUrl; use std::sync::Arc; -use std::sync::mpsc::Sender; #[dom_struct] /// <https://drafts.css-houdini.org/worklets/#workletglobalscope> diff --git a/components/script/lib.rs b/components/script/lib.rs index 6f4ec73272a..fe0f18f7baf 100644 --- a/components/script/lib.rs +++ b/components/script/lib.rs @@ -6,7 +6,6 @@ #![cfg_attr(feature = "unstable", feature(on_unimplemented))] #![feature(const_fn)] #![feature(drain_filter)] -#![feature(mpsc_select)] #![feature(plugin)] #![feature(try_from)] diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 8f9d98a2e93..4f55d49fc17 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -70,7 +70,6 @@ use hyper::header::ReferrerPolicy as ReferrerPolicyHeader; use hyper::mime::{Mime, SubLevel, TopLevel}; use hyper_serde::Serde; use ipc_channel::ipc::{self, IpcSender}; -use ipc_channel::router::ROUTER; use js::glue::GetWindowProxyClass; use js::jsapi::{JSAutoCompartment, JSContext, JS_SetWrapObjectCallbacks}; use js::jsapi::{JSTracer, SetWindowProxyClass}; @@ -101,6 +100,8 @@ use script_traits::CompositorEvent::{KeyEvent, MouseButtonEvent, MouseMoveEvent, use script_traits::webdriver_msg::WebDriverScriptCommand; use serviceworkerjob::{Job, JobQueue}; use servo_atoms::Atom; +use servo_channel::{channel, Receiver, Sender}; +use servo_channel::{route_ipc_receiver_to_new_servo_receiver, route_ipc_receiver_to_new_servo_sender}; use servo_config::opts; use servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl}; use std::cell::Cell; @@ -113,7 +114,6 @@ use std::ptr; use std::rc::Rc; use std::result::Result; use std::sync::Arc; -use std::sync::mpsc::{Receiver, Select, Sender, channel}; use std::thread; use style::thread_state::{self, ThreadState}; use task_queue::{QueuedTask, QueuedTaskConversion, TaskQueue}; @@ -300,39 +300,39 @@ impl OpaqueSender<CommonScriptMsg> for Box<ScriptChan + Send> { impl ScriptPort for Receiver<CommonScriptMsg> { fn recv(&self) -> Result<CommonScriptMsg, ()> { - self.recv().map_err(|_| ()) + self.recv().ok_or(()) } } impl ScriptPort for Receiver<MainThreadScriptMsg> { fn recv(&self) -> Result<CommonScriptMsg, ()> { match self.recv() { - Ok(MainThreadScriptMsg::Common(script_msg)) => Ok(script_msg), - Ok(_) => panic!("unexpected main thread event message!"), - _ => Err(()), + Some(MainThreadScriptMsg::Common(script_msg)) => Ok(script_msg), + Some(_) => panic!("unexpected main thread event message!"), + None => Err(()), } } } impl ScriptPort for Receiver<(TrustedWorkerAddress, CommonScriptMsg)> { fn recv(&self) -> Result<CommonScriptMsg, ()> { - self.recv().map(|(_, msg)| msg).map_err(|_| ()) + self.recv().map(|(_, msg)| msg).ok_or(()) } } impl ScriptPort for Receiver<(TrustedWorkerAddress, MainThreadScriptMsg)> { fn recv(&self) -> Result<CommonScriptMsg, ()> { match self.recv().map(|(_, msg)| msg) { - Ok(MainThreadScriptMsg::Common(script_msg)) => Ok(script_msg), - Ok(_) => panic!("unexpected main thread event message!"), - _ => Err(()), + Some(MainThreadScriptMsg::Common(script_msg)) => Ok(script_msg), + Some(_) => panic!("unexpected main thread event message!"), + None => Err(()), } } } impl ScriptPort for Receiver<(TrustedServiceWorkerAddress, CommonScriptMsg)> { fn recv(&self) -> Result<CommonScriptMsg, ()> { - self.recv().map(|(_, msg)| msg).map_err(|_| ()) + self.recv().map(|(_, msg)| msg).ok_or(()) } } @@ -896,12 +896,12 @@ impl ScriptThread { // Ask the router to proxy IPC messages from the devtools to us. let (ipc_devtools_sender, ipc_devtools_receiver) = ipc::channel().unwrap(); - let devtools_port = ROUTER.route_ipc_receiver_to_new_mpsc_receiver(ipc_devtools_receiver); + let devtools_port = route_ipc_receiver_to_new_servo_receiver(ipc_devtools_receiver); let (timer_event_chan, timer_event_port) = channel(); // Ask the router to proxy IPC messages from the control port to us. - let control_port = ROUTER.route_ipc_receiver_to_new_mpsc_receiver(state.control_port); + let control_port = route_ipc_receiver_to_new_servo_receiver(state.control_port); let boxed_script_sender = Box::new(MainThreadScriptChan(chan.clone())); @@ -1019,37 +1019,15 @@ impl ScriptThread { // Receive at least one message so we don't spinloop. debug!("Waiting for event."); - let mut event = { - let sel = Select::new(); - let mut script_port = sel.handle(self.task_queue.select()); - let mut control_port = sel.handle(&self.control_port); - let mut timer_event_port = sel.handle(&self.timer_event_port); - let mut devtools_port = sel.handle(&self.devtools_port); - let mut image_cache_port = sel.handle(&self.image_cache_port); - unsafe { - script_port.add(); - control_port.add(); - timer_event_port.add(); - if self.devtools_chan.is_some() { - devtools_port.add(); - } - image_cache_port.add(); - } - let ret = sel.wait(); - if ret == script_port.id() { - self.task_queue.take_tasks(); + let mut event = select! { + recv(self.task_queue.select(), msg) => { + self.task_queue.take_tasks(msg.unwrap()); FromScript(self.task_queue.recv().unwrap()) - } else if ret == control_port.id() { - FromConstellation(self.control_port.recv().unwrap()) - } else if ret == timer_event_port.id() { - FromScheduler(self.timer_event_port.recv().unwrap()) - } else if ret == devtools_port.id() { - FromDevtools(self.devtools_port.recv().unwrap()) - } else if ret == image_cache_port.id() { - FromImageCache(self.image_cache_port.recv().unwrap()) - } else { - panic!("unexpected select result") - } + }, + recv(self.control_port.select(), msg) => FromConstellation(msg.unwrap()), + recv(self.timer_event_port.select(), msg) => FromScheduler(msg.unwrap()), + recv(self.devtools_chan.as_ref().map(|_| self.devtools_port.select()), msg) => FromDevtools(msg.unwrap()), + recv(self.image_cache_port.select(), msg) => FromImageCache(msg.unwrap()), }; debug!("Got event."); @@ -1131,20 +1109,20 @@ impl ScriptThread { // and check for more resize events. If there are no events pending, we'll move // on and execute the sequential non-resize events we've seen. match self.control_port.try_recv() { - Err(_) => match self.task_queue.try_recv() { - Err(_) => match self.timer_event_port.try_recv() { - Err(_) => match self.devtools_port.try_recv() { - Err(_) => match self.image_cache_port.try_recv() { - Err(_) => break, - Ok(ev) => event = FromImageCache(ev), + None => match self.task_queue.try_recv() { + None => match self.timer_event_port.try_recv() { + None => match self.devtools_port.try_recv() { + None => match self.image_cache_port.try_recv() { + None => break, + Some(ev) => event = FromImageCache(ev), }, - Ok(ev) => event = FromDevtools(ev), + Some(ev) => event = FromDevtools(ev), }, - Ok(ev) => event = FromScheduler(ev), + Some(ev) => event = FromScheduler(ev), }, - Ok(ev) => event = FromScript(ev), + Some(ev) => event = FromScript(ev), }, - Ok(ev) => event = FromConstellation(ev), + Some(ev) => event = FromConstellation(ev), } } @@ -2200,7 +2178,7 @@ impl ScriptThread { let HistoryTraversalTaskSource(ref history_sender) = self.history_traversal_task_source; let (ipc_timer_event_chan, ipc_timer_event_port) = ipc::channel().unwrap(); - ROUTER.route_ipc_receiver_to_mpsc_sender(ipc_timer_event_port, + route_ipc_receiver_to_new_servo_sender(ipc_timer_event_port, self.timer_event_chan.clone()); let origin = if final_url.as_str() == "about:blank" { diff --git a/components/script/serviceworker_manager.rs b/components/script/serviceworker_manager.rs index 2bf19aa25a5..4573a5666c3 100644 --- a/components/script/serviceworker_manager.rs +++ b/components/script/serviceworker_manager.rs @@ -13,13 +13,12 @@ use dom::bindings::structuredclone::StructuredCloneData; use dom::serviceworkerglobalscope::{ServiceWorkerGlobalScope, ServiceWorkerScriptMsg}; use dom::serviceworkerregistration::longest_prefix_match; use ipc_channel::ipc::{self, IpcSender}; -use ipc_channel::router::ROUTER; use net_traits::{CustomResponseMediator, CoreResourceMsg}; use script_traits::{ServiceWorkerMsg, ScopeThings, SWManagerMsg, SWManagerSenders, DOMMessage}; +use servo_channel::{channel, route_ipc_receiver_to_new_servo_receiver, Sender, Receiver}; use servo_config::prefs::PREFS; use servo_url::ServoUrl; use std::collections::HashMap; -use std::sync::mpsc::{channel, Sender, Receiver, RecvError}; use std::thread; enum Message { @@ -56,8 +55,8 @@ impl ServiceWorkerManager { pub fn spawn_manager(sw_senders: SWManagerSenders) { let (own_sender, from_constellation_receiver) = ipc::channel().unwrap(); let (resource_chan, resource_port) = ipc::channel().unwrap(); - let from_constellation = ROUTER.route_ipc_receiver_to_new_mpsc_receiver(from_constellation_receiver); - let resource_port = ROUTER.route_ipc_receiver_to_new_mpsc_receiver(resource_port); + let from_constellation = route_ipc_receiver_to_new_servo_receiver(from_constellation_receiver); + let resource_port = route_ipc_receiver_to_new_servo_receiver(resource_port); let _ = sw_senders.resource_sender.send(CoreResourceMsg::NetworkMediator(resource_chan)); let _ = sw_senders.swmanager_sender.send(SWManagerMsg::OwnSender(own_sender.clone())); thread::Builder::new().name("ServiceWorkerManager".to_owned()).spawn(move || { @@ -108,7 +107,7 @@ impl ServiceWorkerManager { } fn handle_message(&mut self) { - while let Ok(message) = self.receive_message() { + while let Some(message) = self.receive_message() { let should_continue = match message { Message::FromConstellation(msg) => { self.handle_message_from_constellation(msg) @@ -184,13 +183,10 @@ impl ServiceWorkerManager { true } - #[allow(unsafe_code)] - fn receive_message(&mut self) -> Result<Message, RecvError> { - let msg_from_constellation = &self.own_port; - let msg_from_resource = &self.resource_receiver; + fn receive_message(&mut self) -> Option<Message> { select! { - msg = msg_from_constellation.recv() => msg.map(Message::FromConstellation), - msg = msg_from_resource.recv() => msg.map(Message::FromResource) + recv(self.own_port.select(), msg) => msg.map(Message::FromConstellation), + recv(self.resource_receiver.select(), msg) => msg.map(Message::FromResource), } } } diff --git a/components/script/task_queue.rs b/components/script/task_queue.rs index 7093474e1ed..e7e2117b2f5 100644 --- a/components/script/task_queue.rs +++ b/components/script/task_queue.rs @@ -8,10 +8,10 @@ use dom::bindings::cell::DomRefCell; use dom::worker::TrustedWorkerAddress; use msg::constellation_msg::PipelineId; use script_runtime::ScriptThreadEventCategory; +use servo_channel::{Receiver, Sender, base_channel}; use std::cell::Cell; use std::collections::{HashMap, VecDeque}; use std::default::Default; -use std::sync::mpsc::{Receiver, Sender}; use task::TaskBox; use task_source::TaskSourceName; @@ -59,13 +59,18 @@ impl<T: QueuedTaskConversion> TaskQueue<T> { /// Process incoming tasks, immediately sending priority ones downstream, /// and categorizing potential throttles. - fn process_incoming_tasks(&self) { - let mut non_throttled: Vec<T> = self.port - .try_iter() - .filter(|msg| !msg.is_wake_up()) - .collect(); + fn process_incoming_tasks(&self, first_msg: T) { + let mut incoming = Vec::with_capacity(self.port.len() + 1); + if !first_msg.is_wake_up() { + incoming.push(first_msg); + } + while let Some(msg) = self.port.try_recv() { + if !msg.is_wake_up() { + incoming.push(msg); + } + } - let to_be_throttled: Vec<T> = non_throttled.drain_filter(|msg|{ + let to_be_throttled: Vec<T> = incoming.drain_filter(|msg|{ let task_source = match msg.task_source_name() { Some(task_source) => task_source, None => return false, @@ -80,7 +85,7 @@ impl<T: QueuedTaskConversion> TaskQueue<T> { } }).collect(); - for msg in non_throttled { + for msg in incoming { // Immediately send non-throttled tasks for processing. let _ = self.msg_queue.borrow_mut().push_back(msg); } @@ -101,31 +106,31 @@ impl<T: QueuedTaskConversion> TaskQueue<T> { /// Reset the queue for a new iteration of the event-loop, /// returning the port about whose readiness we want to be notified. - pub fn select(&self) -> &Receiver<T> { + pub fn select(&self) -> &base_channel::Receiver<T> { // This is a new iteration of the event-loop, so we reset the "business" counter. self.taken_task_counter.set(0); // We want to be notified when the script-port is ready to receive. // Hence that's the one we need to include in the select. - &self.port + self.port.select() } /// Take a message from the front of the queue, without waiting if empty. - pub fn recv(&self) -> Result<T, ()> { - self.msg_queue.borrow_mut().pop_front().ok_or(()) + pub fn recv(&self) -> Option<T> { + self.msg_queue.borrow_mut().pop_front() } /// Same as recv. - pub fn try_recv(&self) -> Result<T, ()> { + pub fn try_recv(&self) -> Option<T> { self.recv() } /// Drain the queue for the current iteration of the event-loop. /// Holding-back throttles above a given high-water mark. - pub fn take_tasks(&self) { + pub fn take_tasks(&self, first_msg: T) { // High-watermark: once reached, throttled tasks will be held-back. const PER_ITERATION_MAX: u64 = 5; // Always first check for new tasks, but don't reset 'taken_task_counter'. - self.process_incoming_tasks(); + self.process_incoming_tasks(first_msg); let mut throttled = self.throttled.borrow_mut(); let mut throttled_length: usize = throttled.values().map(|queue| queue.len()).sum(); let task_source_names = TaskSourceName::all(); diff --git a/components/script/task_source/dom_manipulation.rs b/components/script/task_source/dom_manipulation.rs index f184aa3d828..e72110479de 100644 --- a/components/script/task_source/dom_manipulation.rs +++ b/components/script/task_source/dom_manipulation.rs @@ -11,9 +11,9 @@ use msg::constellation_msg::PipelineId; use script_runtime::{CommonScriptMsg, ScriptThreadEventCategory}; use script_thread::MainThreadScriptMsg; use servo_atoms::Atom; +use servo_channel::Sender; use std::fmt; use std::result::Result; -use std::sync::mpsc::Sender; use task::{TaskCanceller, TaskOnce}; use task_source::{TaskSource, TaskSourceName}; diff --git a/components/script/task_source/history_traversal.rs b/components/script/task_source/history_traversal.rs index ffd657adada..7f44ba368b5 100644 --- a/components/script/task_source/history_traversal.rs +++ b/components/script/task_source/history_traversal.rs @@ -4,7 +4,7 @@ use script_runtime::{ScriptChan, CommonScriptMsg}; use script_thread::MainThreadScriptMsg; -use std::sync::mpsc::Sender; +use servo_channel::Sender; #[derive(JSTraceable)] pub struct HistoryTraversalTaskSource(pub Sender<MainThreadScriptMsg>); diff --git a/components/script/task_source/user_interaction.rs b/components/script/task_source/user_interaction.rs index 2beaee95731..d30d54829b5 100644 --- a/components/script/task_source/user_interaction.rs +++ b/components/script/task_source/user_interaction.rs @@ -11,9 +11,9 @@ use msg::constellation_msg::PipelineId; use script_runtime::{CommonScriptMsg, ScriptThreadEventCategory}; use script_thread::MainThreadScriptMsg; use servo_atoms::Atom; +use servo_channel::Sender; use std::fmt; use std::result::Result; -use std::sync::mpsc::Sender; use task::{TaskCanceller, TaskOnce}; use task_source::{TaskSource, TaskSourceName}; diff --git a/components/script_layout_interface/Cargo.toml b/components/script_layout_interface/Cargo.toml index 0abb03ecc8a..820148f3b65 100644 --- a/components/script_layout_interface/Cargo.toml +++ b/components/script_layout_interface/Cargo.toml @@ -17,7 +17,7 @@ cssparser = "0.24" euclid = "0.19" gfx_traits = {path = "../gfx_traits"} html5ever = "0.22" -ipc-channel = "0.10" +ipc-channel = "0.11" libc = "0.2" log = "0.4" time = "0.1.17" @@ -32,6 +32,7 @@ script_traits = {path = "../script_traits"} selectors = { path = "../selectors" } servo_arc = {path = "../servo_arc"} servo_atoms = {path = "../atoms"} +servo_channel = {path = "../channel"} servo_url = {path = "../url"} style = {path = "../style"} webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]} diff --git a/components/script_layout_interface/lib.rs b/components/script_layout_interface/lib.rs index 36c2c2a57ca..5d8f1612f0e 100644 --- a/components/script_layout_interface/lib.rs +++ b/components/script_layout_interface/lib.rs @@ -31,6 +31,7 @@ extern crate script_traits; extern crate selectors; extern crate servo_arc; extern crate servo_atoms; +extern crate servo_channel; extern crate servo_url; extern crate style; extern crate webrender_api; diff --git a/components/script_layout_interface/message.rs b/components/script_layout_interface/message.rs index ac52d9373ce..95f30fbaf97 100644 --- a/components/script_layout_interface/message.rs +++ b/components/script_layout_interface/message.rs @@ -17,9 +17,9 @@ use script_traits::{ScrollState, UntrustedNodeAddress, WindowSizeData}; use script_traits::Painter; use servo_arc::Arc as ServoArc; use servo_atoms::Atom; +use servo_channel::{Receiver, Sender}; use servo_url::ServoUrl; use std::sync::Arc; -use std::sync::mpsc::{Receiver, Sender}; use style::context::QuirksMode; use style::properties::PropertyId; use style::selector_parser::PseudoElement; diff --git a/components/script_traits/Cargo.toml b/components/script_traits/Cargo.toml index c7eacee52f7..42a46ac3bdf 100644 --- a/components/script_traits/Cargo.toml +++ b/components/script_traits/Cargo.toml @@ -19,7 +19,7 @@ euclid = "0.19" gfx_traits = {path = "../gfx_traits"} hyper = "0.10" hyper_serde = "0.8" -ipc-channel = "0.10" +ipc-channel = "0.11" libc = "0.2" malloc_size_of = { path = "../malloc_size_of" } malloc_size_of_derive = { path = "../malloc_size_of_derive" } @@ -29,6 +29,7 @@ profile_traits = {path = "../profile_traits"} rustc-serialize = "0.3.4" serde = "1.0" servo_atoms = {path = "../atoms"} +servo_channel = {path = "../channel"} servo_url = {path = "../url"} style_traits = {path = "../style_traits", features = ["servo"]} time = "0.1.12" diff --git a/components/script_traits/lib.rs b/components/script_traits/lib.rs index 02b4bd7efed..d92c5f1b82e 100644 --- a/components/script_traits/lib.rs +++ b/components/script_traits/lib.rs @@ -30,6 +30,7 @@ extern crate profile_traits; extern crate rustc_serialize; #[macro_use] extern crate serde; extern crate servo_atoms; +extern crate servo_channel; extern crate servo_url; extern crate style_traits; extern crate time; @@ -60,12 +61,12 @@ use profile_traits::mem; use profile_traits::time as profile_time; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use servo_atoms::Atom; +use servo_channel::{Receiver, Sender}; use servo_url::ImmutableOrigin; use servo_url::ServoUrl; use std::collections::HashMap; use std::fmt; use std::sync::Arc; -use std::sync::mpsc::{Receiver, Sender, RecvTimeoutError}; use style_traits::CSSPixel; use style_traits::SpeculativePainter; use style_traits::cursor::CursorKind; @@ -804,12 +805,6 @@ pub enum PaintWorkletError { WorkletNotFound, } -impl From<RecvTimeoutError> for PaintWorkletError { - fn from(_: RecvTimeoutError) -> PaintWorkletError { - PaintWorkletError::Timeout - } -} - /// Execute paint code in the worklet thread pool. pub trait Painter: SpeculativePainter { /// <https://drafts.css-houdini.org/css-paint-api/#draw-a-paint-image> diff --git a/components/servo/Cargo.toml b/components/servo/Cargo.toml index 816025e1071..423d6814810 100644 --- a/components/servo/Cargo.toml +++ b/components/servo/Cargo.toml @@ -32,6 +32,7 @@ canvas = {path = "../canvas"} canvas_traits = {path = "../canvas_traits"} compositing = {path = "../compositing", features = ["gleam"]} constellation = {path = "../constellation"} +crossbeam-channel = "0.2" debugger = {path = "../debugger"} devtools = {path = "../devtools"} devtools_traits = {path = "../devtools_traits"} @@ -40,7 +41,7 @@ env_logger = "0.5" euclid = "0.19" gfx = {path = "../gfx"} gleam = "0.6" -ipc-channel = "0.10" +ipc-channel = "0.11" layout_thread = {path = "../layout_thread"} log = "0.4" msg = {path = "../msg"} diff --git a/components/servo/lib.rs b/components/servo/lib.rs index e5fc7107322..dba8ce702df 100644 --- a/components/servo/lib.rs +++ b/components/servo/lib.rs @@ -28,7 +28,6 @@ pub extern crate bluetooth; pub extern crate bluetooth_traits; pub extern crate canvas; pub extern crate canvas_traits; -pub extern crate servo_channel; pub extern crate compositing; pub extern crate constellation; pub extern crate debugger; @@ -47,6 +46,7 @@ pub extern crate profile_traits; pub extern crate script; pub extern crate script_traits; pub extern crate script_layout_interface; +pub extern crate servo_channel; pub extern crate servo_config; pub extern crate servo_geometry; pub extern crate servo_url; @@ -96,13 +96,13 @@ use profile::time as profile_time; use profile_traits::mem; use profile_traits::time; use script_traits::{ConstellationMsg, SWManagerSenders, ScriptToConstellationChan}; +use servo_channel::{Sender, channel}; use servo_config::opts; use servo_config::prefs::PREFS; use std::borrow::Cow; use std::cmp::max; use std::path::PathBuf; use std::rc::Rc; -use std::sync::mpsc::{Sender, channel}; use webrender::RendererKind; use webvr::{WebVRThread, WebVRCompositorHandler}; @@ -276,7 +276,7 @@ where WindowEvent::LoadUrl(top_level_browsing_context_id, url) => { let msg = ConstellationMsg::LoadUrl(top_level_browsing_context_id, url); if let Err(e) = self.constellation_chan.send(msg) { - warn!("Sending load url to constellation failed ({}).", e); + warn!("Sending load url to constellation failed ({:?}).", e); } }, @@ -314,14 +314,14 @@ where let msg = ConstellationMsg::TraverseHistory(top_level_browsing_context_id, direction); if let Err(e) = self.constellation_chan.send(msg) { - warn!("Sending navigation to constellation failed ({}).", e); + warn!("Sending navigation to constellation failed ({:?}).", e); } }, WindowEvent::KeyEvent(ch, key, state, modifiers) => { let msg = ConstellationMsg::KeyEvent(ch, key, state, modifiers); if let Err(e) = self.constellation_chan.send(msg) { - warn!("Sending key event to constellation failed ({}).", e); + warn!("Sending key event to constellation failed ({:?}).", e); } }, @@ -332,7 +332,7 @@ where WindowEvent::Reload(top_level_browsing_context_id) => { let msg = ConstellationMsg::Reload(top_level_browsing_context_id); if let Err(e) = self.constellation_chan.send(msg) { - warn!("Sending reload to constellation failed ({}).", e); + warn!("Sending reload to constellation failed ({:?}).", e); } }, @@ -348,7 +348,7 @@ where let msg = ConstellationMsg::NewBrowser(url, browser_id); if let Err(e) = self.constellation_chan.send(msg) { warn!( - "Sending NewBrowser message to constellation failed ({}).", + "Sending NewBrowser message to constellation failed ({:?}).", e ); } @@ -358,7 +358,7 @@ where let msg = ConstellationMsg::SelectBrowser(ctx); if let Err(e) = self.constellation_chan.send(msg) { warn!( - "Sending SelectBrowser message to constellation failed ({}).", + "Sending SelectBrowser message to constellation failed ({:?}).", e ); } @@ -368,7 +368,7 @@ where let msg = ConstellationMsg::CloseBrowser(ctx); if let Err(e) = self.constellation_chan.send(msg) { warn!( - "Sending CloseBrowser message to constellation failed ({}).", + "Sending CloseBrowser message to constellation failed ({:?}).", e ); } @@ -377,7 +377,7 @@ where WindowEvent::SendError(ctx, e) => { let msg = ConstellationMsg::SendError(ctx, e); if let Err(e) = self.constellation_chan.send(msg) { - warn!("Sending SendError message to constellation failed ({}).", e); + warn!("Sending SendError message to constellation failed ({:?}).", e); } }, } diff --git a/components/style/Cargo.toml b/components/style/Cargo.toml index 951ed615d99..b56624e62d1 100644 --- a/components/style/Cargo.toml +++ b/components/style/Cargo.toml @@ -21,7 +21,7 @@ gecko = ["num_cpus", use_bindgen = ["bindgen", "regex", "toml"] servo = ["serde", "style_traits/servo", "servo_atoms", "servo_config", "html5ever", "cssparser/serde", "encoding_rs", "malloc_size_of/servo", "arrayvec/use_union", - "servo_url", "string_cache"] + "servo_url", "string_cache", "servo_channel"] gecko_debug = [] [dependencies] @@ -59,6 +59,7 @@ selectors = { path = "../selectors" } serde = {version = "1.0", optional = true, features = ["derive"]} servo_arc = { path = "../servo_arc" } servo_atoms = {path = "../atoms", optional = true} +servo_channel = {path = "../channel", optional = true} servo_config = {path = "../config", optional = true} smallbitvec = "2.1.1" smallvec = "0.6.2" diff --git a/components/style/animation.rs b/components/style/animation.rs index 3e501781987..bcb42653cbd 100644 --- a/components/style/animation.rs +++ b/components/style/animation.rs @@ -15,8 +15,8 @@ use properties::longhands::animation_direction::computed_value::single_value::T use properties::longhands::animation_play_state::computed_value::single_value::T as AnimationPlayState; use rule_tree::CascadeLevel; use servo_arc::Arc; +use servo_channel::Sender; use std::fmt; -use std::sync::mpsc::Sender; use stylesheets::keyframes_rule::{KeyframesAnimation, KeyframesStep, KeyframesStepValue}; use timer::Timer; use values::computed::Time; diff --git a/components/style/context.rs b/components/style/context.rs index 16bba2a863f..0623cb05a4a 100644 --- a/components/style/context.rs +++ b/components/style/context.rs @@ -32,14 +32,14 @@ use selectors::matching::ElementSelectorFlags; use servo_arc::Arc; #[cfg(feature = "servo")] use servo_atoms::Atom; +#[cfg(feature = "servo")] +use servo_channel::Sender; use shared_lock::StylesheetGuards; use sharing::StyleSharingCache; use std::fmt; use std::ops; #[cfg(feature = "servo")] use std::sync::Mutex; -#[cfg(feature = "servo")] -use std::sync::mpsc::Sender; use style_traits::CSSPixel; use style_traits::DevicePixel; #[cfg(feature = "servo")] diff --git a/components/style/lib.rs b/components/style/lib.rs index 57d507a4ab4..1f50e062545 100644 --- a/components/style/lib.rs +++ b/components/style/lib.rs @@ -84,6 +84,7 @@ pub extern crate servo_arc; #[cfg(feature = "servo")] #[macro_use] extern crate servo_atoms; +#[cfg(feature = "servo")] extern crate servo_channel; #[cfg(feature = "servo")] extern crate servo_config; #[cfg(feature = "servo")] diff --git a/components/webdriver_server/Cargo.toml b/components/webdriver_server/Cargo.toml index bcf6cccd4e6..959cc07b868 100644 --- a/components/webdriver_server/Cargo.toml +++ b/components/webdriver_server/Cargo.toml @@ -15,13 +15,14 @@ cookie = "0.10" euclid = "0.19" hyper = "0.10" image = "0.19" -ipc-channel = "0.10" +ipc-channel = "0.11" log = "0.4" msg = {path = "../msg"} net_traits = {path = "../net_traits"} regex = "1.0" rustc-serialize = "0.3.4" script_traits = {path = "../script_traits"} +servo_channel = {path = "../channel"} servo_config = {path = "../config"} servo_url = {path = "../url"} url = "1.2" diff --git a/components/webdriver_server/lib.rs b/components/webdriver_server/lib.rs index 4caf137d32f..b4c61a1ddce 100644 --- a/components/webdriver_server/lib.rs +++ b/components/webdriver_server/lib.rs @@ -19,6 +19,7 @@ extern crate net_traits; extern crate regex; extern crate rustc_serialize; extern crate script_traits; +extern crate servo_channel; extern crate servo_config; extern crate servo_url; extern crate uuid; @@ -38,12 +39,12 @@ use rustc_serialize::json::{Json, ToJson}; use script_traits::{ConstellationMsg, LoadData, WebDriverCommandMsg}; use script_traits::webdriver_msg::{LoadStatus, WebDriverCookieError, WebDriverFrameId}; use script_traits::webdriver_msg::{WebDriverJSError, WebDriverJSResult, WebDriverScriptCommand}; +use servo_channel::Sender; use servo_config::prefs::{PREFS, PrefValue}; use servo_url::ServoUrl; use std::borrow::ToOwned; use std::collections::BTreeMap; use std::net::{SocketAddr, SocketAddrV4}; -use std::sync::mpsc::Sender; use std::thread; use std::time::Duration; use uuid::Uuid; @@ -1180,7 +1181,7 @@ impl WebDriverHandler<ServoExtensionRoute> for Handler { fn delete_session(&mut self, _session: &Option<Session>) { // Servo doesn't support multiple sessions, so we exit on session deletion - let _ = self.constellation_chan.send(ConstellationMsg::Exit); + let _ = self.constellation_chan.send(ConstellationMsg::Exit).unwrap(); self.session = None; } } diff --git a/components/webvr/Cargo.toml b/components/webvr/Cargo.toml index 6a850f14739..b2b3791b725 100644 --- a/components/webvr/Cargo.toml +++ b/components/webvr/Cargo.toml @@ -16,10 +16,11 @@ oculusvr = ['rust-webvr/oculusvr'] [dependencies] canvas_traits = {path = "../canvas_traits"} euclid = "0.19" -ipc-channel = "0.10" +ipc-channel = "0.11" log = "0.4" msg = {path = "../msg"} rust-webvr = {version = "0.9", features = ["openvr"]} script_traits = {path = "../script_traits"} +servo_channel = {path = "../channel"} servo_config = {path = "../config"} webvr_traits = {path = "../webvr_traits" } diff --git a/components/webvr/lib.rs b/components/webvr/lib.rs index 77bc6e32134..c4708580e2d 100644 --- a/components/webvr/lib.rs +++ b/components/webvr/lib.rs @@ -12,6 +12,7 @@ extern crate log; extern crate msg; extern crate rust_webvr; extern crate script_traits; +extern crate servo_channel; extern crate servo_config; extern crate webvr_traits; diff --git a/components/webvr/webvr_thread.rs b/components/webvr/webvr_thread.rs index ac2d4671de6..55d7e31c7c6 100644 --- a/components/webvr/webvr_thread.rs +++ b/components/webvr/webvr_thread.rs @@ -9,11 +9,10 @@ use ipc_channel::ipc::{IpcReceiver, IpcSender}; use msg::constellation_msg::PipelineId; use rust_webvr::VRServiceManager; use script_traits::ConstellationMsg; +use servo_channel::{channel, Receiver, Sender}; use servo_config::prefs::PREFS; use std::{thread, time}; use std::collections::{HashMap, HashSet}; -use std::sync::mpsc; -use std::sync::mpsc::{Receiver, Sender}; use webvr_traits::{WebVRMsg, WebVRResult}; use webvr_traits::webvr::*; @@ -72,7 +71,7 @@ impl WebVRThread { vr_compositor_chan: WebVRCompositorSender, ) -> (IpcSender<WebVRMsg>, Sender<Sender<ConstellationMsg>>) { let (sender, receiver) = ipc::channel().unwrap(); - let (constellation_sender, constellation_receiver) = mpsc::channel(); + let (constellation_sender, constellation_receiver) = channel(); let sender_clone = sender.clone(); thread::Builder::new() .name("WebVRThread".into()) @@ -358,7 +357,7 @@ pub type WebVRCompositorSender = Sender<Option<WebVRCompositor>>; impl WebVRCompositorHandler { pub fn new() -> (Box<WebVRCompositorHandler>, WebVRCompositorSender) { - let (sender, receiver) = mpsc::channel(); + let (sender, receiver) = channel(); let instance = Box::new(WebVRCompositorHandler { compositors: HashMap::new(), webvr_thread_receiver: receiver, diff --git a/components/webvr_traits/Cargo.toml b/components/webvr_traits/Cargo.toml index 19a2879db38..4451ccd369a 100644 --- a/components/webvr_traits/Cargo.toml +++ b/components/webvr_traits/Cargo.toml @@ -10,7 +10,7 @@ name = "webvr_traits" path = "lib.rs" [dependencies] -ipc-channel = "0.10" +ipc-channel = "0.11" msg = {path = "../msg"} rust-webvr-api = {version = "0.9", features = ["serde-serialization"]} serde = "1.0" diff --git a/ports/servo/Cargo.toml b/ports/servo/Cargo.toml index 4ca42dd0ec7..a31f6306514 100644 --- a/ports/servo/Cargo.toml +++ b/ports/servo/Cargo.toml @@ -33,6 +33,8 @@ unstable = ["libservo/unstable"] [target.'cfg(not(target_os = "android"))'.dependencies] backtrace = "0.3" +bitflags = "1.0" +crossbeam-channel = "0.2" euclid = "0.19" gleam = "0.6" glutin = "0.18" diff --git a/servo-tidy.toml b/servo-tidy.toml index 46f4fa505c5..49ea33afc8d 100644 --- a/servo-tidy.toml +++ b/servo-tidy.toml @@ -14,7 +14,7 @@ lint-scripts = [ # which are packages allowed to use the blocked package. [blocked-packages] rand = [ - "crossbeam-channel", + "crossbeam-channel", # Used to initialize a thread-local "gaol", "hashglobe", # only uses in tests "ipc-channel", @@ -38,8 +38,6 @@ packages = [ "bitflags", "crossbeam-epoch", "crossbeam-utils", - #TODO: remove ipc-channel when #21325 lands - "ipc-channel", "log", "rand", "winapi", diff --git a/tests/unit/metrics/Cargo.toml b/tests/unit/metrics/Cargo.toml index a9cbeab2e08..7a4636345d7 100644 --- a/tests/unit/metrics/Cargo.toml +++ b/tests/unit/metrics/Cargo.toml @@ -11,7 +11,7 @@ doctest = false [dependencies] gfx_traits = {path = "../../../components/gfx_traits"} -ipc-channel = "0.10" +ipc-channel = "0.11" layout = {path = "../../../components/layout"} metrics = {path = "../../../components/metrics"} msg = {path = "../../../components/msg"} diff --git a/tests/unit/profile/Cargo.toml b/tests/unit/profile/Cargo.toml index d3feb410884..707941e4846 100644 --- a/tests/unit/profile/Cargo.toml +++ b/tests/unit/profile/Cargo.toml @@ -10,7 +10,7 @@ path = "lib.rs" doctest = false [dependencies] -ipc-channel = "0.10" +ipc-channel = "0.11" profile = {path = "../../../components/profile"} profile_traits = {path = "../../../components/profile_traits"} |