From 80f5c39dcc37e9a8c023feac1695b8e6b415ea22 Mon Sep 17 00:00:00 2001 From: afinch7 Date: Fri, 19 Jul 2019 16:09:48 -0400 Subject: [PATCH] use std::future --- Cargo.lock | 766 +++++++++++++++++++++++++++++++++--- build_extra/rust/BUILD.gn | 239 +++++++++++ build_extra/rust/rust.gni | 7 +- cli/BUILD.gn | 7 +- cli/Cargo.toml | 16 +- cli/compiler.rs | 74 ++-- cli/deno_dir.rs | 218 +++++----- cli/dispatch_minimal.rs | 89 +++-- cli/flags.rs | 29 +- cli/fs.rs | 3 +- cli/global_timer.rs | 12 +- cli/http_body.rs | 51 +-- cli/http_util.rs | 237 +++++++---- cli/import_map.rs | 169 ++++---- cli/main.rs | 84 ++-- cli/msg.rs | 5 +- cli/ops.rs | 414 +++++++++---------- cli/permissions.rs | 4 +- cli/repl.rs | 7 +- cli/resolve_addr.rs | 29 +- cli/resources.rs | 232 +++++++---- cli/shell.rs | 32 +- cli/source_maps.rs | 6 +- cli/state.rs | 43 +- cli/tokio_util.rs | 86 ++-- cli/tokio_write.rs | 62 --- cli/worker.rs | 166 ++++---- core/BUILD.gn | 19 +- core/Cargo.toml | 2 +- core/examples/http_bench.rs | 207 +++++----- core/flags.rs | 3 +- core/isolate.rs | 220 ++++++----- core/js_errors.rs | 6 +- core/modules.rs | 562 +++++++++++++------------- third_party | 2 +- 35 files changed, 2655 insertions(+), 1453 deletions(-) delete mode 100644 cli/tokio_write.rs diff --git a/Cargo.lock b/Cargo.lock index 4deb87a354741..7db7957e6fcc9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -21,6 +21,11 @@ name = "arc-swap" version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "arc-waker" +version = "0.1.0" +source = "git+https://github.com/tokio-rs/async#e1b3ba3dd8278222d7b62e77c76ef309c7498d3c" + [[package]] name = "argon2rs" version = "0.2.5" @@ -38,6 +43,11 @@ dependencies = [ "nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "async-util" +version = "0.1.0" +source = "git+https://github.com/tokio-rs/async#e1b3ba3dd8278222d7b62e77c76ef309c7498d3c" + [[package]] name = "atty" version = "0.2.11" @@ -111,6 +121,15 @@ dependencies = [ "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "c2-chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "cc" version = "1.0.37" @@ -148,6 +167,15 @@ name = "constant_time_eq" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "crossbeam-channel" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "crossbeam-deque" version = "0.7.1" @@ -178,6 +206,15 @@ dependencies = [ "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "crossbeam-utils" +version = "0.6.5" +source = "git+https://github.com/stjepang/crossbeam?branch=raw-parker#e2a7760f071d9db280c9e4ddd6195e77a5f7bb2f" +dependencies = [ + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "crossbeam-utils" version = "0.6.5" @@ -199,7 +236,7 @@ dependencies = [ name = "deno" version = "0.12.0" dependencies = [ - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -218,7 +255,8 @@ dependencies = [ "deno 0.12.0", "dirs 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "flatbuffers 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", "fwdansi 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.12.30 (registry+https://github.com/rust-lang/crates.io-index)", @@ -240,13 +278,12 @@ dependencies = [ "source-map-mappings 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.0.8 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-fs 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-process 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-rustls 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-threadpool 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)", + "tokio-executor 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)", + "tokio-fs 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)", + "tokio-io 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)", + "tokio-process 0.2.4 (git+https://github.com/afinch7/tokio-process?rev=320b8b9bfe77c195a15d14e3f293ade438b7d5c5)", + "tokio-threadpool 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "utime 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -341,7 +378,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "futures" -version = "0.1.27" +version = "0.1.28" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "futures-channel-preview" +version = "0.3.0-alpha.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures-core-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "futures-core-preview" +version = "0.3.0-alpha.17" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -349,10 +400,62 @@ name = "futures-cpupool" version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "futures-executor-preview" +version = "0.3.0-alpha.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures-channel-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-util-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "futures-io-preview" +version = "0.3.0-alpha.17" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "futures-preview" +version = "0.3.0-alpha.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures-channel-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-executor-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-io-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-util-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "futures-sink-preview" +version = "0.3.0-alpha.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures-core-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "futures-util-preview" +version = "0.3.0-alpha.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-channel-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-io-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "fwdansi" version = "1.0.1" @@ -362,6 +465,15 @@ dependencies = [ "termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "getrandom" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "h2" version = "0.1.23" @@ -370,7 +482,7 @@ dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -395,7 +507,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-buf 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -411,7 +523,7 @@ version = "0.12.30" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "h2 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)", "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", @@ -441,7 +553,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "ct-logs 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.12.30 (registry+https://github.com/rust-lang/crates.io-index)", "rustls 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -505,6 +617,9 @@ dependencies = [ name = "lazy_static" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "libc" @@ -520,6 +635,14 @@ dependencies = [ "scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "lock_api" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "log" version = "0.4.6" @@ -658,6 +781,16 @@ dependencies = [ "parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "parking_lot" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lock_api 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot_core 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "parking_lot_core" version = "0.4.0" @@ -670,11 +803,35 @@ dependencies = [ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "parking_lot_core" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "percent-encoding" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "pin-utils" +version = "0.1.0-alpha.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "ppv-lite86" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "proc-macro2" version = "0.4.30" @@ -721,6 +878,18 @@ dependencies = [ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rand" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "getrandom 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_chacha 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rand_chacha" version = "0.1.1" @@ -730,6 +899,16 @@ dependencies = [ "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rand_chacha" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rand_core" version = "0.3.1" @@ -743,6 +922,14 @@ name = "rand_core" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "rand_core" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "getrandom 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rand_hc" version = "0.1.0" @@ -751,6 +938,14 @@ dependencies = [ "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rand_isaac" version = "0.1.1" @@ -929,6 +1124,11 @@ name = "scopeguard" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "scopeguard" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "sct" version = "0.5.0" @@ -977,15 +1177,6 @@ dependencies = [ "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "signal-hook" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "signal-hook-registry 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "signal-hook-registry" version = "1.0.1" @@ -1133,7 +1324,7 @@ version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1151,6 +1342,58 @@ dependencies = [ "tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "tokio" +version = "0.2.0" +source = "git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1#0d99ddd4f4adfb3ee099a5eefaea529200afcbd1" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-codec 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)", + "tokio-current-thread 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)", + "tokio-executor 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)", + "tokio-fs 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)", + "tokio-futures 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)", + "tokio-io 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)", + "tokio-macros 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)", + "tokio-reactor 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)", + "tokio-sync 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)", + "tokio-tcp 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)", + "tokio-threadpool 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)", + "tokio-timer 0.3.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)", + "tokio-udp 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)", + "tokio-uds 0.3.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)", + "tracing-core 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tokio" +version = "0.2.0" +source = "git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8#d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-codec 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)", + "tokio-current-thread 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)", + "tokio-executor 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)", + "tokio-fs 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)", + "tokio-futures 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)", + "tokio-io 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)", + "tokio-macros 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)", + "tokio-reactor 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)", + "tokio-sync 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)", + "tokio-tcp 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)", + "tokio-threadpool 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)", + "tokio-timer 0.3.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)", + "tokio-udp 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)", + "tokio-uds 0.3.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)", + "tracing-core 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "tokio-buf" version = "0.1.1" @@ -1158,7 +1401,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1167,26 +1410,82 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "tokio-codec" +version = "0.2.0" +source = "git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1#0d99ddd4f4adfb3ee099a5eefaea529200afcbd1" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-futures 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)", + "tokio-io 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)", +] + +[[package]] +name = "tokio-codec" +version = "0.2.0" +source = "git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8#d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-futures 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)", + "tokio-io 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)", +] + [[package]] name = "tokio-current-thread" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "tokio-current-thread" +version = "0.2.0" +source = "git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1#0d99ddd4f4adfb3ee099a5eefaea529200afcbd1" +dependencies = [ + "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)", +] + +[[package]] +name = "tokio-current-thread" +version = "0.2.0" +source = "git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8#d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8" +dependencies = [ + "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)", +] + [[package]] name = "tokio-executor" version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tokio-executor" +version = "0.2.0" +source = "git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1#0d99ddd4f4adfb3ee099a5eefaea529200afcbd1" +dependencies = [ + "crossbeam-utils 0.6.5 (git+https://github.com/stjepang/crossbeam?branch=raw-parker)", +] + +[[package]] +name = "tokio-executor" +version = "0.2.0" +source = "git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8#d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8" +dependencies = [ + "crossbeam-utils 0.6.5 (git+https://github.com/stjepang/crossbeam?branch=raw-parker)", ] [[package]] @@ -1194,33 +1493,118 @@ name = "tokio-fs" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-threadpool 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "tokio-fs" +version = "0.2.0" +source = "git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1#0d99ddd4f4adfb3ee099a5eefaea529200afcbd1" +dependencies = [ + "futures-core-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-futures 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)", + "tokio-io 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)", + "tokio-threadpool 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)", +] + +[[package]] +name = "tokio-fs" +version = "0.2.0" +source = "git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8#d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8" +dependencies = [ + "futures-core-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-futures 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)", + "tokio-io 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)", + "tokio-threadpool 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)", +] + +[[package]] +name = "tokio-futures" +version = "0.2.0" +source = "git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1#0d99ddd4f4adfb3ee099a5eefaea529200afcbd1" +dependencies = [ + "futures-core-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tokio-futures" +version = "0.2.0" +source = "git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8#d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8" +dependencies = [ + "futures-core-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "tokio-io" version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tokio-io" +version = "0.2.0" +source = "git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1#0d99ddd4f4adfb3ee099a5eefaea529200afcbd1" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tokio-io" +version = "0.2.0" +source = "git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8#d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "tokio-macros" +version = "0.2.0" +source = "git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1#0d99ddd4f4adfb3ee099a5eefaea529200afcbd1" +dependencies = [ + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.36 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tokio-macros" +version = "0.2.0" +source = "git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8#d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8" +dependencies = [ + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.36 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "tokio-process" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" +version = "0.2.4" +source = "git+https://github.com/afinch7/tokio-process?rev=320b8b9bfe77c195a15d14e3f293ade438b7d5c5#320b8b9bfe77c195a15d14e3f293ade438b7d5c5" dependencies = [ - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-util-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "mio-named-pipes 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-signal 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)", + "tokio-io 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)", + "tokio-reactor 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)", + "tokio-signal 0.3.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1230,7 +1614,7 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1242,12 +1626,48 @@ dependencies = [ "tokio-sync 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "tokio-reactor" +version = "0.2.0" +source = "git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1#0d99ddd4f4adfb3ee099a5eefaea529200afcbd1" +dependencies = [ + "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)", + "tokio-io 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)", + "tokio-sync 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)", +] + +[[package]] +name = "tokio-reactor" +version = "0.2.0" +source = "git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8#d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8" +dependencies = [ + "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)", + "tokio-io 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)", + "tokio-sync 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)", +] + [[package]] name = "tokio-rustls" version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "rustls 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "webpki 0.19.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1255,17 +1675,20 @@ dependencies = [ [[package]] name = "tokio-signal" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" +version = "0.3.0" +source = "git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8#d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8" dependencies = [ - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-util-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", - "signal-hook 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "signal-hook-registry 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)", + "tokio-io 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)", + "tokio-reactor 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)", + "tokio-sync 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1275,7 +1698,29 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tokio-sync" +version = "0.2.0" +source = "git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1#0d99ddd4f4adfb3ee099a5eefaea529200afcbd1" +dependencies = [ + "async-util 0.1.0 (git+https://github.com/tokio-rs/async)", + "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-futures 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)", +] + +[[package]] +name = "tokio-sync" +version = "0.2.0" +source = "git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8#d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8" +dependencies = [ + "async-util 0.1.0 (git+https://github.com/tokio-rs/async)", + "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-futures 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)", ] [[package]] @@ -1284,13 +1729,41 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "tokio-tcp" +version = "0.2.0" +source = "git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1#0d99ddd4f4adfb3ee099a5eefaea529200afcbd1" +dependencies = [ + "async-util 0.1.0 (git+https://github.com/tokio-rs/async)", + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)", + "tokio-reactor 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)", +] + +[[package]] +name = "tokio-tcp" +version = "0.2.0" +source = "git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8#d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8" +dependencies = [ + "async-util 0.1.0 (git+https://github.com/tokio-rs/async)", + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)", + "tokio-reactor 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)", +] + [[package]] name = "tokio-threadpool" version = "0.1.14" @@ -1299,7 +1772,7 @@ dependencies = [ "crossbeam-deque 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1307,17 +1780,79 @@ dependencies = [ "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "tokio-threadpool" +version = "0.2.0" +source = "git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1#0d99ddd4f4adfb3ee099a5eefaea529200afcbd1" +dependencies = [ + "arc-waker 0.1.0 (git+https://github.com/tokio-rs/async)", + "crossbeam-deque 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)", + "tokio-sync 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)", +] + +[[package]] +name = "tokio-threadpool" +version = "0.2.0" +source = "git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8#d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8" +dependencies = [ + "arc-waker 0.1.0 (git+https://github.com/tokio-rs/async)", + "crossbeam-deque 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)", + "tokio-sync 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)", +] + [[package]] name = "tokio-timer" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "tokio-timer" +version = "0.3.0" +source = "git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1#0d99ddd4f4adfb3ee099a5eefaea529200afcbd1" +dependencies = [ + "async-util 0.1.0 (git+https://github.com/tokio-rs/async)", + "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)", + "tokio-sync 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)", +] + +[[package]] +name = "tokio-timer" +version = "0.3.0" +source = "git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8#d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8" +dependencies = [ + "async-util 0.1.0 (git+https://github.com/tokio-rs/async)", + "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)", + "tokio-sync 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)", +] + [[package]] name = "tokio-trace-core" version = "0.2.0" @@ -1332,7 +1867,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1340,13 +1875,35 @@ dependencies = [ "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "tokio-udp" +version = "0.2.0" +source = "git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1#0d99ddd4f4adfb3ee099a5eefaea529200afcbd1" +dependencies = [ + "futures-core-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-reactor 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)", +] + +[[package]] +name = "tokio-udp" +version = "0.2.0" +source = "git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8#d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8" +dependencies = [ + "futures-core-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-reactor 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)", +] + [[package]] name = "tokio-uds" version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1357,6 +1914,48 @@ dependencies = [ "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "tokio-uds" +version = "0.3.0" +source = "git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1#0d99ddd4f4adfb3ee099a5eefaea529200afcbd1" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", + "mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-codec 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)", + "tokio-io 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)", + "tokio-reactor 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)", +] + +[[package]] +name = "tokio-uds" +version = "0.3.0" +source = "git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8#d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", + "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", + "mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-codec 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)", + "tokio-io 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)", + "tokio-reactor 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)", +] + +[[package]] +name = "tracing-core" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "try-lock" version = "0.2.2" @@ -1453,7 +2052,7 @@ name = "want" version = "0.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1535,8 +2134,10 @@ dependencies = [ "checksum aho-corasick 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e6f484ae0c99fec2e858eb6134949117399f222608d84cadb3f58c1f97c2364c" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum arc-swap 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "bc4662175ead9cd84451d5c35070517777949a2ed84551764129cedb88384841" +"checksum arc-waker 0.1.0 (git+https://github.com/tokio-rs/async)" = "" "checksum argon2rs 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3f67b0b6a86dae6e67ff4ca2b6201396074996379fba2b92ff649126f37cb392" "checksum arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "92c7fb76bc8826a8b33b4ee5bb07a247a81e76764ab4d55e8f73e3a4d8808c71" +"checksum async-util 0.1.0 (git+https://github.com/tokio-rs/async)" = "" "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" "checksum autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0e49efa51329a5fd37e7c79db4621af617cd4e3e5bc224939808d076077077bf" "checksum backtrace 0.3.30 (registry+https://github.com/rust-lang/crates.io-index)" = "ada4c783bb7e7443c14e0480f429ae2cc99da95065aeab7ee1b81ada0419404f" @@ -1546,14 +2147,17 @@ dependencies = [ "checksum blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" "checksum bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" +"checksum c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7d64d04786e0f528460fc884753cf8dddcc466be308f6026f8e355c41a0e4101" "checksum cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)" = "39f75544d7bbaf57560d2168f28fd649ff9c76153874db88bdbdfd839b1a7e7d" "checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" "checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" "checksum constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8ff012e225ce166d4422e0e78419d901719760f62ae2b7969ca6b564d1b54a9e" +"checksum crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "0f0ed1a4de2235cabda8558ff5840bffb97fcb64c97827f354a451307df5f72b" "checksum crossbeam-deque 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b18cd2e169ad86297e6bc0ad9aa679aee9daa4f19e8163860faf7c164e4f5a71" "checksum crossbeam-epoch 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "04c9e3102cc2d69cd681412141b390abd55a362afc1540965dad0ad4d34280b4" "checksum crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b" +"checksum crossbeam-utils 0.6.5 (git+https://github.com/stjepang/crossbeam?branch=raw-parker)" = "" "checksum crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f8306fcef4a7b563b76b7dd949ca48f52bc1141aa067d2ea09565f3e2652aa5c" "checksum ct-logs 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1b4660f8b07a560a88c02d76286edb9f0d5d64e495d2b0f233186155aa51be1f" "checksum dirs 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3fd78930633bd1c6e35c4b42b1df7b0cbc6bc191146e512bb3bedf243fcc3901" @@ -1567,9 +2171,17 @@ dependencies = [ "checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" -"checksum futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)" = "a2037ec1c6c1c4f79557762eab1f7eae1f64f6cb418ace90fae88f0942b60139" +"checksum futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "45dc39533a6cae6da2b56da48edae506bb767ec07370f86f70fc062e9d435869" +"checksum futures-channel-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)" = "21c71ed547606de08e9ae744bb3c6d80f5627527ef31ecf2a7210d0e67bc8fae" +"checksum futures-core-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)" = "4b141ccf9b7601ef987f36f1c0d9522f76df3bba1cf2e63bfacccc044c4558f5" "checksum futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4" +"checksum futures-executor-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)" = "87ba260fe51080ba37f063ad5b0732c4ff1f737ea18dcb67833d282cdc2c6f14" +"checksum futures-io-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)" = "082e402605fcb8b1ae1e5ba7d7fdfd3e31ef510e2a8367dd92927bb41ae41b3a" +"checksum futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)" = "bf25f91c8a9a1f64c451e91b43ba269ed359b9f52d35ed4b3ce3f9c842435867" +"checksum futures-sink-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)" = "4309a25a1069a1f3c10647b227b9afe6722b67a030d3f00a9cbdc171fc038de4" +"checksum futures-util-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)" = "af8198c48b222f02326940ce2b3aa9e6e91a32886eeaad7ca3b8e4c70daa3f4e" "checksum fwdansi 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "34dd4c507af68d37ffef962063dfa1944ce0dd4d5b82043dbab1dabe088610c3" +"checksum getrandom 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "e65cce4e5084b14874c4e7097f38cab54f47ee554f9194673456ea379dcc4c55" "checksum h2 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)" = "1e42e3daed5a7e17b12a0c23b5b2fbff23a925a570938ebee4baca1a9a1a2240" "checksum http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "eed324f0f0daf6ec10c474f150505af2c143f251722bf9dbd1261bd1f2ee2c1a" "checksum http-body 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6741c859c1b2463a423a1dbce98d418e6c3c3fc720fb0d45528657320920292d" @@ -1585,6 +2197,7 @@ dependencies = [ "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" "checksum libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)" = "6281b86796ba5e4366000be6e9e18bf35580adf9e63fbe2294aadb587613a319" "checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" +"checksum lock_api 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f8912e782533a93a167888781b836336a6ca5da6175c05944c86cf28c31104dc" "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" "checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" "checksum memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2efc7bc57c883d4a4d6e3246905283d8dae951bb3bd32f49d6ef297f546e1c39" @@ -1601,16 +2214,24 @@ dependencies = [ "checksum numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef" "checksum owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49a4b8ea2179e6a2e27411d3bca09ca6dd630821cf6894c6c7c8467a8ee7ef13" "checksum parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ab41b4aed082705d1056416ae4468b6ea99d52599ecf3169b00088d43113e337" +"checksum parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" "checksum parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9" +"checksum parking_lot_core 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "67812d70a819b886655846594086c00ac1f3e8b77c36ef494aa730c620b19d57" "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" +"checksum pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587" +"checksum ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b" "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" "checksum quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "faf4799c5d274f3868a4aae320a0a182cbd2baee377b378f080e16a23e9d80db" "checksum rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" "checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" +"checksum rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d47eab0e83d9693d40f825f86948aa16eff6750ead4bdffc4ab95b8b3a7f052c" "checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" +"checksum rand_chacha 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e193067942ef6f485a349a113329140d0ab9e2168ce92274499bb0e9a4190d9d" "checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" "checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0" +"checksum rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "615e683324e75af5d43d8f7a39ffe3ee4a9dc42c5c701167a71dc59c3a493aca" "checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" +"checksum rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" "checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" "checksum rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" "checksum rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" @@ -1631,13 +2252,13 @@ dependencies = [ "checksum ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "b96a9549dc8d48f2c283938303c4b5a77aa29bfbc5b54b084fb1630408899a8f" "checksum scoped_threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1d51f5df5af43ab3f1360b429fa5e0152ac5ce8c0bd6485cae490332e96846a8" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" +"checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" "checksum sct 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f5adf8fbd58e1b1b52699dc8bed2630faecb6d8c7bee77d009d6bbe4af569b9" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)" = "32746bf0f26eab52f06af0d0aa1984f641341d06d8d673c693871da2d188c9be" "checksum serde_derive 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)" = "46a3223d0c9ba936b61c0d2e3e559e3217dbfb8d65d06d26e8b3c25de38bae3e" "checksum serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)" = "5a23aa71d4a4d43fdbfaac00eff68ba8a06a51759a89ac3304323e800c4dd40d" -"checksum signal-hook 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "72ab58f1fda436857e6337dcb6a5aaa34f16c5ddc87b3a8b6ef7a212f90b9c5a" "checksum signal-hook-registry 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cded4ffa32146722ec54ab1f16320568465aa922aa9ab4708129599740da85d7" "checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" "checksum smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "ab606a9c5e214920bb66c458cd7be8ef094f813f20fe77a54cc7dbfff220d4b7" @@ -1656,23 +2277,54 @@ dependencies = [ "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" "checksum tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)" = "ec2ffcf4bcfc641413fa0f1427bf8f91dfc78f56a6559cbf50e04837ae442a87" +"checksum tokio 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)" = "" +"checksum tokio 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)" = "" "checksum tokio-buf 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8fb220f46c53859a4b7ec083e41dec9778ff0b1851c0942b211edb89e0ccdc46" "checksum tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5c501eceaf96f0e1793cf26beb63da3d11c738c4a943fdf3746d81d64684c39f" +"checksum tokio-codec 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)" = "" +"checksum tokio-codec 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)" = "" "checksum tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "d16217cad7f1b840c5a97dfb3c43b0c871fef423a6e8d2118c604e843662a443" +"checksum tokio-current-thread 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)" = "" +"checksum tokio-current-thread 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)" = "" "checksum tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "83ea44c6c0773cc034771693711c35c677b4b5a4b21b9e7071704c54de7d555e" +"checksum tokio-executor 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)" = "" +"checksum tokio-executor 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)" = "" "checksum tokio-fs 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe6dc22b08d6993916647d108a1a7d15b9cd29c4f4496c62b92c45b5041b7af" +"checksum tokio-fs 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)" = "" +"checksum tokio-fs 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)" = "" +"checksum tokio-futures 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)" = "" +"checksum tokio-futures 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)" = "" "checksum tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "5090db468dad16e1a7a54c8c67280c5e4b544f3d3e018f0b913b400261f85926" -"checksum tokio-process 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "88e1281e412013f1ff5787def044a9577a0bed059f451e835f1643201f8b777d" +"checksum tokio-io 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)" = "" +"checksum tokio-io 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)" = "" +"checksum tokio-macros 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)" = "" +"checksum tokio-macros 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)" = "" +"checksum tokio-process 0.2.4 (git+https://github.com/afinch7/tokio-process?rev=320b8b9bfe77c195a15d14e3f293ade438b7d5c5)" = "" "checksum tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6af16bfac7e112bea8b0442542161bfc41cbfa4466b580bdda7d18cb88b911ce" +"checksum tokio-reactor 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)" = "" +"checksum tokio-reactor 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)" = "" "checksum tokio-rustls 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1600e90b2602df28ff54ae842519b408fbb25378c3c5aee1b795593e9263dc80" -"checksum tokio-signal 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "dd6dc5276ea05ce379a16de90083ec80836440d5ef8a6a39545a3207373b8296" +"checksum tokio-signal 0.3.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)" = "" "checksum tokio-sync 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2162248ff317e2bc713b261f242b69dbb838b85248ed20bb21df56d60ea4cae7" +"checksum tokio-sync 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)" = "" +"checksum tokio-sync 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)" = "" "checksum tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1d14b10654be682ac43efee27401d792507e30fd8d26389e1da3b185de2e4119" +"checksum tokio-tcp 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)" = "" +"checksum tokio-tcp 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)" = "" "checksum tokio-threadpool 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "72558af20be886ea124595ea0f806dd5703b8958e4705429dd58b3d8231f72f2" +"checksum tokio-threadpool 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)" = "" +"checksum tokio-threadpool 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)" = "" "checksum tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "f2106812d500ed25a4f38235b9cae8f78a09edf43203e16e59c3b769a342a60e" +"checksum tokio-timer 0.3.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)" = "" +"checksum tokio-timer 0.3.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)" = "" "checksum tokio-trace-core 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9c8a256d6956f7cb5e2bdfe8b1e8022f1a09206c6c2b1ba00f3b746b260c613" "checksum tokio-udp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "66268575b80f4a4a710ef83d087fdfeeabdce9b74c797535fbac18a2cb906e92" +"checksum tokio-udp 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)" = "" +"checksum tokio-udp 0.2.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)" = "" "checksum tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "037ffc3ba0e12a0ab4aca92e5234e0dedeb48fddf6ccd260f1f150a36a9f2445" +"checksum tokio-uds 0.3.0 (git+https://github.com/tokio-rs/tokio?rev=0d99ddd4f4adfb3ee099a5eefaea529200afcbd1)" = "" +"checksum tokio-uds 0.3.0 (git+https://github.com/tokio-rs/tokio?rev=d0bb16192b70be73eb7be3f5f7d9979c91e0f9a8)" = "" +"checksum tracing-core 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b15b1e1f124b19a23d87d54613077bf5249e5f13a5cd39e2f2a50afef938ca05" "checksum try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382" "checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" diff --git a/build_extra/rust/BUILD.gn b/build_extra/rust/BUILD.gn index 8151eb89fa200..1d6a539046d83 100644 --- a/build_extra/rust/BUILD.gn +++ b/build_extra/rust/BUILD.gn @@ -321,6 +321,236 @@ rust_rlib("futures_cpupool") { ] } +rust_rlib("futures_preview") { + source_root = "$cargo_home/registry/src/github.com-1ecc6299db9ec823/futures-preview-0.3.0-alpha.17/src/lib.rs" + crate_name = "futures" + crate_version = "0.3.0-alpha.17" + features = [ + "default", + "std", + "alloc", + "compat", + ] + extern = [ + { + label = ":futures_channel_preview" + crate_name = "futures_channel" + crate_type = "rlib" + crate_version = "0.3.0-alpha.17" + }, + { + label = ":futures_core_preview" + crate_name = "futures_core" + crate_type = "rlib" + crate_version = "0.3.0-alpha.17" + }, + { + label = ":futures_executor_preview" + crate_name = "futures_executor" + crate_type = "rlib" + crate_version = "0.3.0-alpha.17" + }, + { + label = ":futures_io_preview" + crate_name = "futures_io" + crate_type = "rlib" + crate_version = "0.3.0-alpha.17" + }, + { + label = ":futures_sink_preview" + crate_name = "futures_sink" + crate_type = "rlib" + crate_version = "0.3.0-alpha.17" + }, + { + label = ":futures_util_preview" + crate_name = "futures_util" + crate_type = "rlib" + crate_version = "0.3.0-alpha.17" + }, + ] + args = [ + "--cap-lints", + "allow", + ] +} + +rust_rlib("futures_channel_preview") { + source_root = "$cargo_home/registry/src/github.com-1ecc6299db9ec823/futures-channel-preview-0.3.0-alpha.17/src/lib.rs" + crate_name = "futures_channel" + crate_version = "0.3.0-alpha.17" + features = [ + "default", + "std", + "alloc", + "sink", + ] + extern = [ + { + label = ":futures_core_preview" + crate_name = "futures_core" + crate_type = "rlib" + crate_version = "0.3.0-alpha.17" + }, + { + label = ":futures_sink_preview" + crate_name = "futures_sink" + crate_type = "rlib" + crate_version = "0.3.0-alpha.17" + }, + ] + args = [ + "--cap-lints", + "allow", + ] +} + +rust_rlib("futures_core_preview") { + source_root = "$cargo_home/registry/src/github.com-1ecc6299db9ec823/futures-core-preview-0.3.0-alpha.17/src/lib.rs" + crate_name = "futures_core" + crate_version = "0.3.0-alpha.17" + features = [ + "default", + "std", + "alloc", + ] + args = [ + "--cap-lints", + "allow", + ] +} + +rust_rlib("futures_executor_preview") { + source_root = "$cargo_home/registry/src/github.com-1ecc6299db9ec823/futures-executor-preview-0.3.0-alpha.17/src/lib.rs" + crate_name = "futures_executor" + crate_version = "0.3.0-alpha.17" + features = [ + "default", + "std", + "alloc", + ] + extern_rlib = [ "num_cpus" ] + extern = [ + { + label = ":futures_core_preview" + crate_name = "futures_core" + crate_type = "rlib" + crate_version = "0.3.0-alpha.17" + }, + { + label = ":futures_sink_preview" + crate_name = "futures_sink" + crate_type = "rlib" + crate_version = "0.3.0-alpha.17" + }, + { + label = ":futures_util_preview" + crate_name = "futures_util" + crate_type = "rlib" + crate_version = "0.3.0-alpha.17" + }, + ] + args = [ + "--cap-lints", + "allow", + ] +} + +rust_rlib("futures_io_preview") { + source_root = "$cargo_home/registry/src/github.com-1ecc6299db9ec823/futures-io-preview-0.3.0-alpha.17/src/lib.rs" + crate_name = "futures_io" + crate_version = "0.3.0-alpha.17" + features = [ + "default", + "std", + "alloc", + ] + args = [ + "--cap-lints", + "allow", + ] +} + +rust_rlib("futures_sink_preview") { + source_root = "$cargo_home/registry/src/github.com-1ecc6299db9ec823/futures-sink-preview-0.3.0-alpha.17/src/lib.rs" + crate_name = "futures_sink" + crate_version = "0.3.0-alpha.17" + features = [ + "default", + "std", + "alloc", + ] + extern = [ + { + label = ":futures_core_preview" + crate_name = "futures_core" + crate_type = "rlib" + crate_version = "0.3.0-alpha.17" + }, + ] + args = [ + "--cap-lints", + "allow", + ] +} + +rust_rlib("futures_util_preview") { + source_root = "$cargo_home/registry/src/github.com-1ecc6299db9ec823/futures-util-preview-0.3.0-alpha.17/src/lib.rs" + crate_name = "futures_util" + crate_version = "0.3.0-alpha.17" + features = [ + "default", + "std", + "alloc", + "sink", + "io", + "channel", + "compat", + ] + extern_rlib = [ + "futures", + "slab", + "pin_utils", + "memchr", + ] + extern = [ + { + label = ":futures" + crate_name = "futures" + crate_type = "rlib" + extern_alias = "futures_01" + }, + { + label = ":futures_channel_preview" + crate_name = "futures_channel" + crate_type = "rlib" + crate_version = "0.3.0-alpha.17" + }, + { + label = ":futures_core_preview" + crate_name = "futures_core" + crate_type = "rlib" + crate_version = "0.3.0-alpha.17" + }, + { + label = ":futures_io_preview" + crate_name = "futures_io" + crate_type = "rlib" + crate_version = "0.3.0-alpha.17" + }, + { + label = ":futures_sink_preview" + crate_name = "futures_sink" + crate_type = "rlib" + crate_version = "0.3.0-alpha.17" + }, + ] + args = [ + "--cap-lints", + "allow", + ] +} + rust_rlib("h2") { edition = "2015" source_root = "$cargo_home/registry/src/github.com-1ecc6299db9ec823/h2-0.1.23/src/lib.rs" @@ -764,6 +994,15 @@ rust_rlib("percent_encoding") { ] } +rust_rlib("pin_utils") { + edition = "2015" + source_root = "$cargo_home/registry/src/github.com-1ecc6299db9ec823/pin-utils-0.1.0-alpha.4/src/lib.rs" + args = [ + "--cap-lints", + "allow", + ] +} + rust_rlib("proc_macro2") { edition = "2015" source_root = "$cargo_home/registry/src/github.com-1ecc6299db9ec823/proc-macro2-0.4.30/src/lib.rs" diff --git a/build_extra/rust/rust.gni b/build_extra/rust/rust.gni index b4c128e710ee3..a7af81144e3ec 100644 --- a/build_extra/rust/rust.gni +++ b/build_extra/rust/rust.gni @@ -150,6 +150,11 @@ template("_rust_crate") { label = info.label crate_name = info.crate_name crate_type = info.crate_type + extern_name = info.crate_name + + if (defined(info.extern_alias)) { + extern_name = info.extern_alias + } if (!defined(info.crate_version)) { crate_suffix = "" @@ -293,7 +298,7 @@ template("_rust_crate") { foreach(info, extern_outputs) { args += [ "--extern", - info.crate_name + "=" + rebase_path(info.out_path, root_build_dir), + info.extern_name + "=" + rebase_path(info.out_path, root_build_dir), ] sources += [ info.out_path ] deps += [ info.label ] diff --git a/cli/BUILD.gn b/cli/BUILD.gn index 7f19f8b952662..1e0fa03309588 100644 --- a/cli/BUILD.gn +++ b/cli/BUILD.gn @@ -18,6 +18,12 @@ main_extern = [ crate_name = "serde_derive" crate_type = "proc_macro" }, + { + label = "//build_extra/rust:futures_preview" + crate_name = "futures" + crate_type = "rlib" + crate_version = "0.3.0-alpha.17" + }, ] main_extern_rlib = [ "ansi_term", @@ -25,7 +31,6 @@ main_extern_rlib = [ "clap", "dirs", "flatbuffers", - "futures", "fwdansi", "http", "hyper", diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 08364348f2ca6..2b532c5423ed9 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -23,7 +23,8 @@ atty = "0.2.11" clap = "2.33.0" dirs = "2.0.1" flatbuffers = "0.6.0" -futures = "0.1.27" +futures-preview = { version = "0.3.0-alpha.17", features = ["compat"] } +futures_01 = { package = "futures", version = "0.1.28" } http = "0.1.17" hyper = "0.12.30" hyper-rustls = "0.16.1" @@ -43,13 +44,12 @@ serde_json = { version = "1.0.39", features = [ "preserve_order" ] } source-map-mappings = "0.5.0" tempfile = "3.0.8" termcolor = "1.0.4" -tokio = "0.1.21" -tokio-executor = "0.1.7" -tokio-fs = "0.1.6" -tokio-io = "0.1.12" -tokio-process = "0.2.3" -tokio-rustls = "0.9.3" -tokio-threadpool = "0.1.14" +tokio = { version = "0.2.0", git = "https://github.com/tokio-rs/tokio", rev = "0d99ddd4f4adfb3ee099a5eefaea529200afcbd1" } +tokio-executor = { version = "0.2.0", git = "https://github.com/tokio-rs/tokio", rev = "0d99ddd4f4adfb3ee099a5eefaea529200afcbd1" } +tokio-fs = { version = "0.2.0", git = "https://github.com/tokio-rs/tokio", rev = "0d99ddd4f4adfb3ee099a5eefaea529200afcbd1" } +tokio-io = { version = "0.2.0", git = "https://github.com/tokio-rs/tokio", rev = "0d99ddd4f4adfb3ee099a5eefaea529200afcbd1" } +tokio-process = { version = "0.2.0", git = "https://github.com/afinch7/tokio-process", rev = "320b8b9bfe77c195a15d14e3f293ade438b7d5c5" } +tokio-threadpool = { version = "0.2.0", git = "https://github.com/tokio-rs/tokio", rev = "0d99ddd4f4adfb3ee099a5eefaea529200afcbd1" } url = "1.7.2" utime = "0.2.1" diff --git a/cli/compiler.rs b/cli/compiler.rs index 6e1399b44559b..dc39397d51ea5 100644 --- a/cli/compiler.rs +++ b/cli/compiler.rs @@ -14,13 +14,12 @@ use crate::worker::Worker; use deno::Buf; use deno::ErrBox; use deno::ModuleSpecifier; -use futures::future::Either; -use futures::Future; -use futures::Stream; +use futures::future::{self, Either, FutureExt, TryFutureExt}; use ring; use std::collections::HashSet; use std::fmt::Write; use std::fs; +use std::future::Future; use std::path::PathBuf; use std::str; use std::sync::atomic::Ordering; @@ -221,7 +220,7 @@ impl TsCompiler { state: ThreadSafeState, module_name: String, out_file: String, - ) -> impl Future { + ) -> impl Future> { debug!( "Invoking the compiler to bundle. module_name: {}", module_name @@ -243,10 +242,7 @@ impl TsCompiler { std::process::exit(1); } debug!("Sent message to worker"); - let stream_future = - resources::get_message_stream_from_worker(compiler_rid) - .into_future(); - stream_future.map(|(f, _rest)| f).map_err(|(f, _rest)| f) + resources::get_message_from_worker(compiler_rid) }); first_msg_fut.map_err(|_| panic!("not handled")).and_then( @@ -257,11 +253,11 @@ impl TsCompiler { let json_str = std::str::from_utf8(&msg).unwrap(); debug!("Message: {}", json_str); if let Some(diagnostics) = Diagnostic::from_emit_result(json_str) { - return Err(ErrBox::from(diagnostics)); + return future::err(ErrBox::from(diagnostics)); } } - Ok(()) + future::ok(()) }, ) } @@ -290,20 +286,20 @@ impl TsCompiler { self: &Self, state: ThreadSafeState, source_file: &SourceFile, - ) -> impl Future { + ) -> impl Future> { // TODO: maybe fetching of original SourceFile should be done here? if source_file.media_type != msg::MediaType::TypeScript { - return Either::A(futures::future::ok(source_file.clone())); + return Either::Right(futures::future::ok(source_file.clone())); } if self.has_compiled(&source_file.url) { match self.get_compiled_source_file(&source_file) { Ok(compiled_module) => { - return Either::A(futures::future::ok(compiled_module)); + return Either::Right(futures::future::ok(compiled_module)); } Err(err) => { - return Either::A(futures::future::err(err)); + return Either::Right(futures::future::err(err)); } } } @@ -330,7 +326,7 @@ impl TsCompiler { compiled_module.clone().filename ); // TODO: store in in-process cache for subsequent access - return Either::A(futures::future::ok(compiled_module)); + return Either::Right(futures::future::ok(compiled_module)); } } } @@ -365,10 +361,7 @@ impl TsCompiler { std::process::exit(1); } debug!("Sent message to worker"); - let stream_future = - resources::get_message_stream_from_worker(compiler_rid) - .into_future(); - stream_future.map(|(f, _rest)| f).map_err(|(f, _rest)| f) + resources::get_message_from_worker(compiler_rid) }); let fut = first_msg_fut @@ -380,35 +373,40 @@ impl TsCompiler { let json_str = std::str::from_utf8(&msg).unwrap(); debug!("Message: {}", json_str); if let Some(diagnostics) = Diagnostic::from_emit_result(json_str) { - return Err(ErrBox::from(diagnostics)); + return future::err(ErrBox::from(diagnostics)); } } - Ok(()) - }).and_then(move |_| { + future::ok(()) + }) + .and_then(move |_| { // if we are this far it means compilation was successful and we can // load compiled filed from disk // TODO: can this be somehow called using `self.`? - state_ - .ts_compiler - .get_compiled_source_file(&source_file_) - .map_err(|e| { - // TODO: this situation shouldn't happen - panic!("Expected to find compiled file: {}", e) - }) - }).and_then(move |source_file_after_compile| { + future::ready( + state_ + .ts_compiler + .get_compiled_source_file(&source_file_) + .map_err(|e| { + // TODO: this situation shouldn't happen + panic!("Expected to find compiled file: {}", e) + }), + ) + }) + .and_then(move |source_file_after_compile| { // Explicit drop to keep reference alive until future completes. drop(compiling_job); - Ok(source_file_after_compile) - }).then(move |r| { + future::ok(source_file_after_compile) + }) + .then(move |r| { debug!(">>>>> compile_sync END"); // TODO(ry) do this in worker's destructor. // resource.close(); - r + future::ready(r) }); - Either::B(fut) + Either::Left(fut) } /// Get associated `CompiledFileMetadata` for given module if it exists. @@ -648,11 +646,9 @@ mod tests { .ts_compiler .compile_sync(mock_state.clone(), &out) .unwrap(); - assert!( - out - .source_code - .starts_with("console.log(\"Hello World\");".as_bytes()) - ); + assert!(out + .source_code + .starts_with("console.log(\"Hello World\");".as_bytes())); }) } diff --git a/cli/deno_dir.rs b/cli/deno_dir.rs index 91a39543db928..b471686ebf546 100644 --- a/cli/deno_dir.rs +++ b/cli/deno_dir.rs @@ -10,15 +10,16 @@ use crate::tokio_util; use deno::ErrBox; use deno::ModuleSpecifier; use dirs; -use futures::future::{loop_fn, Either, Loop}; -use futures::Future; +use futures::future::{self, Either, FutureExt, TryFutureExt}; use http; use serde_json; use std; use std::collections::HashMap; use std::fs; +use std::future::Future; use std::path::Path; use std::path::PathBuf; +use std::pin::Pin; use std::result::Result; use std::str; use std::str::FromStr; @@ -62,7 +63,7 @@ impl SourceFile { } pub type SourceFileFuture = - dyn Future + Send; + dyn Future> + Send; /// This trait implements synchronous and asynchronous methods /// for file fetching. @@ -75,13 +76,15 @@ pub trait SourceFileFetcher { fn fetch_source_file_async( self: &Self, specifier: &ModuleSpecifier, - ) -> Box; + ) -> Pin>; /// Required for TS compiler. fn fetch_source_file( self: &Self, specifier: &ModuleSpecifier, - ) -> Result; + ) -> Result { + tokio_util::block_on(self.fetch_source_file_async(specifier)) + } } // TODO: this list should be implemented on SourceFileFetcher trait @@ -191,14 +194,14 @@ impl SourceFileFetcher for DenoDir { fn fetch_source_file_async( self: &Self, specifier: &ModuleSpecifier, - ) -> Box { + ) -> Pin> { let module_url = specifier.as_url().to_owned(); debug!("fetch_source_file. specifier {} ", &module_url); // Check if this file was already fetched and can be retrieved from in-process cache. if let Some(source_file) = self.source_file_cache.get(specifier.to_string()) { - return Box::new(futures::future::ok(source_file)); + return futures::future::ok(source_file).boxed(); } let source_file_cache = self.source_file_cache.clone(); @@ -209,14 +212,16 @@ impl SourceFileFetcher for DenoDir { &module_url, self.use_disk_cache, self.no_remote_fetch, - ).then(move |result| { + ) + .map(move |result| { let mut out = result.map_err(|err| { if err.kind() == ErrorKind::NotFound { // For NotFound, change the message to something better. DenoError::new( ErrorKind::NotFound, format!("Cannot resolve module \"{}\"", module_url.to_string()), - ).into() + ) + .into() } else { err } @@ -233,14 +238,7 @@ impl SourceFileFetcher for DenoDir { Ok(out) }); - Box::new(fut) - } - - fn fetch_source_file( - self: &Self, - specifier: &ModuleSpecifier, - ) -> Result { - tokio_util::block_on(self.fetch_source_file_async(specifier)) + fut.boxed() } } @@ -260,22 +258,22 @@ impl DenoDir { module_url: &Url, use_disk_cache: bool, no_remote_fetch: bool, - ) -> impl Future { + ) -> impl Future> { let url_scheme = module_url.scheme(); let is_local_file = url_scheme == "file"; if let Err(err) = DenoDir::check_if_supported_scheme(&module_url) { - return Either::A(futures::future::err(err)); + return Either::Right(futures::future::err(err)); } // Local files are always fetched from disk bypassing cache entirely. if is_local_file { match self.fetch_local_file(&module_url) { Ok(source_file) => { - return Either::A(futures::future::ok(source_file)); + return Either::Right(futures::future::ok(source_file)); } Err(err) => { - return Either::A(futures::future::err(err)); + return Either::Right(futures::future::err(err)); } } } @@ -284,13 +282,13 @@ impl DenoDir { if use_disk_cache { match self.fetch_cached_remote_source(&module_url, None) { Ok(Some(source_file)) => { - return Either::A(futures::future::ok(source_file)); + return Either::Right(futures::future::ok(source_file)); } Ok(None) => { // there's no cached version } Err(err) => { - return Either::A(futures::future::err(err)); + return Either::Right(futures::future::err(err)); } } } @@ -298,33 +296,37 @@ impl DenoDir { // If remote file wasn't found check if we can fetch it if no_remote_fetch { // We can't fetch remote file - bail out - return Either::A(futures::future::err( + return Either::Right(futures::future::err( std::io::Error::new( std::io::ErrorKind::NotFound, format!( "cannot find remote file '{}' in cache", module_url.to_string() ), - ).into(), + ) + .into(), )); } // Fetch remote file and cache on-disk for subsequent access // not cached/local, try remote. let module_url_ = module_url.clone(); - Either::B(self + Either::Left( + self .fetch_remote_source_async(&module_url) // TODO: cache fetched remote source here - `fetch_remote_source` should only fetch with // redirects, nothing more .and_then(move |maybe_remote_source| match maybe_remote_source { - Some(output) => Ok(output), - None => Err( + Some(output) => future::ok(output), + None => future::err( std::io::Error::new( std::io::ErrorKind::NotFound, format!("cannot find remote file '{}'", module_url_.to_string()), - ).into(), + ) + .into(), ), - })) + }), + ) } /// Fetch local source file. @@ -424,7 +426,7 @@ impl DenoDir { fn fetch_remote_source_async( self: &Self, module_url: &Url, - ) -> impl Future, Error = ErrBox> { + ) -> impl Future, ErrBox>> { use crate::http_util::FetchOnceResult; let download_job = self.progress.add("Download", &module_url.to_string()); @@ -433,89 +435,78 @@ impl DenoDir { // cached file, containing just the media type and possible redirect target (both are http headers). // If redirect target is present, the file itself if not cached. // In future resolutions, we would instead follow this redirect target ("redirect_to"). - loop_fn( - ( - self.clone(), - None, - module_url.clone(), - ), - |( - dir, - mut maybe_initial_module_url, - module_url, - )| { + let dir = self.clone(); + let mut maybe_initial_module_url = None; + let mut module_url = module_url.clone(); + let loop_fut = async move { + loop { let module_uri = url_into_uri(&module_url); // Single pass fetch, either yields code or yields redirect. - http_util::fetch_string_once(module_uri).and_then( - move |fetch_once_result| { - match fetch_once_result { - FetchOnceResult::Redirect(uri) => { - // If redirects, update module_name and filename for next looped call. - let new_module_url = Url::parse(&uri.to_string()).expect("http::uri::Uri should be parseable as Url"); - - if maybe_initial_module_url.is_none() { - maybe_initial_module_url = Some(module_url); - } - - // Not yet completed. Follow the redirect and loop. - Ok(Loop::Continue(( - dir, - maybe_initial_module_url, - new_module_url, - ))) - } - FetchOnceResult::Code(source, maybe_content_type) => { - // TODO: move caching logic outside this function - // We land on the code. - dir.save_source_code_headers( - &module_url, + let fetch_once_result = + http_util::fetch_string_once(module_uri).await?; + match fetch_once_result { + FetchOnceResult::Redirect(uri) => { + if maybe_initial_module_url.is_none() { + maybe_initial_module_url = Some(module_url); + } + + // If redirects, update module_name and filename for next looped call. + module_url = Url::parse(&uri.to_string()) + .expect("http::uri::Uri should be parseable as Url"); + + // Not yet completed. Follow the redirect and loop. + continue; + } + FetchOnceResult::Code(source, maybe_content_type) => { + // TODO: move caching logic outside this function + // We land on the code. + dir + .save_source_code_headers( + &module_url, + maybe_content_type.clone(), + None, + ) + .unwrap(); + + dir.save_source_code(&module_url, &source).unwrap(); + + if let Some(redirect_source_url) = &maybe_initial_module_url { + dir + .save_source_code_headers( + redirect_source_url, maybe_content_type.clone(), - None, - ).unwrap(); - - - dir.save_source_code( - &module_url, - &source - ).unwrap(); - - if let Some(redirect_source_url) = &maybe_initial_module_url { - dir.save_source_code_headers( - redirect_source_url, - maybe_content_type.clone(), - Some(module_url.to_string()) - ).unwrap() - } - - let filepath = dir - .deps_cache - .location - .join(dir.deps_cache.get_cache_filename(&module_url)); - - let media_type = map_content_type( - &filepath, - maybe_content_type.as_ref().map(String::as_str), - ); - - let source_file = SourceFile { - url: module_url, - redirect_source_url: maybe_initial_module_url, - filename: filepath, - media_type, - source_code: source.as_bytes().to_owned(), - }; - - Ok(Loop::Break(Some(source_file))) - } + Some(module_url.to_string()), + ) + .unwrap() } - }, - ) - }, - ) - .then(move |r| { + + let filepath = dir + .deps_cache + .location + .join(dir.deps_cache.get_cache_filename(&module_url)); + + let media_type = map_content_type( + &filepath, + maybe_content_type.as_ref().map(String::as_str), + ); + + let source_file = SourceFile { + url: module_url, + redirect_source_url: maybe_initial_module_url, + filename: filepath, + media_type, + source_code: source.as_bytes().to_owned(), + }; + + return Ok(Some(source_file)); + } + } + } + }; + loop_fut.then(move |r| { // Explicit drop to keep reference alive until future completes. drop(download_job); - r + future::ready(r) }) } @@ -875,11 +866,9 @@ mod tests { // If get_source_file does not call remote, this should be JavaScript // as we modified before! (we do not overwrite .headers.json due to no http fetch) assert_eq!(&(r3.media_type), &msg::MediaType::Json); - assert!( - fs::read_to_string(&headers_file_name) - .unwrap() - .contains("application/json") - ); + assert!(fs::read_to_string(&headers_file_name) + .unwrap() + .contains("application/json")); // let's create fresh instance of DenoDir (simulating another freshh Deno process) // and don't use cache @@ -969,7 +958,8 @@ mod tests { tokio_util::init(|| { let specifier = ModuleSpecifier::resolve_url( "http://localhost:4545/tests/subdir/mismatch_ext.ts", - ).unwrap(); + ) + .unwrap(); let headers_file_name = deno_dir.deps_cache.location.join( deno_dir.deps_cache.get_cache_filename_with_extension( specifier.as_url(), diff --git a/cli/dispatch_minimal.rs b/cli/dispatch_minimal.rs index 9d82595d15f65..1260aa60b0f42 100644 --- a/cli/dispatch_minimal.rs +++ b/cli/dispatch_minimal.rs @@ -9,7 +9,8 @@ use deno::Buf; use deno::CoreOp; use deno::Op; use deno::PinnedBuf; -use futures::Future; +use futures::future; +use futures::future::FutureExt; const DISPATCH_MINIMAL_TOKEN: i32 = 0xCAFE; const OP_READ: i32 = 1; @@ -100,24 +101,27 @@ pub fn dispatch_minimal( let state = state.clone(); - let fut = Box::new(min_op.then(move |result| -> Result { - match result { - Ok(r) => { - record.result = r; + let fut = min_op + .then(move |result| { + match result { + Ok(r) => { + record.result = r; + } + Err(err) => { + // TODO(ry) The dispatch_minimal doesn't properly pipe errors back to + // the caller. + debug!("swallowed err {}", err); + record.result = -1; + } } - Err(err) => { - // TODO(ry) The dispatch_minimal doesn't properly pipe errors back to - // the caller. - debug!("swallowed err {}", err); - record.result = -1; - } - } - let buf: Buf = record.into(); - state.metrics_op_completed(buf.len()); - Ok(buf) - })); + let buf: Buf = record.into(); + state.metrics_op_completed(buf.len()); + future::ready(buf) + }) + .boxed(); + if is_sync { - Op::Sync(fut.wait().unwrap()) + Op::Sync(futures::executor::block_on(fut)) } else { Op::Async(fut) } @@ -126,46 +130,57 @@ pub fn dispatch_minimal( mod ops { use crate::deno_error; use crate::resources; - use crate::tokio_write; use deno::ErrBox; use deno::PinnedBuf; - use futures::Future; + use futures::future; + use futures::future::FutureExt; + use futures::future::TryFutureExt; + use std::future::Future; + use std::pin::Pin; - type MinimalOp = dyn Future + Send; + type MinimalOp = dyn Future> + Send; - pub fn read(rid: i32, zero_copy: Option) -> Box { + pub fn read(rid: i32, zero_copy: Option) -> Pin> { debug!("read rid={}", rid); - let zero_copy = match zero_copy { + let mut zero_copy = match zero_copy { None => { - return Box::new(futures::future::err(deno_error::no_buffer_specified())) + return future::err(deno_error::no_buffer_specified()).boxed(); } Some(buf) => buf, }; match resources::lookup(rid as u32) { - None => Box::new(futures::future::err(deno_error::bad_resource())), - Some(resource) => Box::new( - tokio::io::read(resource, zero_copy) - .map_err(ErrBox::from) - .and_then(move |(_resource, _buf, nread)| Ok(nread as i32)), - ), + None => future::err(deno_error::bad_resource()).boxed(), + Some(mut resource) => async move { + let nread = tokio::io::AsyncReadExt::read( + &mut resource, + &mut zero_copy.as_mut()[..], + ) + .map_err(ErrBox::from) + .await?; + Ok(nread as i32) + } + .boxed(), } } - pub fn write(rid: i32, zero_copy: Option) -> Box { + pub fn write(rid: i32, zero_copy: Option) -> Pin> { debug!("write rid={}", rid); let zero_copy = match zero_copy { None => { - return Box::new(futures::future::err(deno_error::no_buffer_specified())) + return future::err(deno_error::no_buffer_specified()).boxed(); } Some(buf) => buf, }; match resources::lookup(rid as u32) { - None => Box::new(futures::future::err(deno_error::bad_resource())), - Some(resource) => Box::new( - tokio_write::write(resource, zero_copy) - .map_err(ErrBox::from) - .and_then(move |(_resource, _buf, nwritten)| Ok(nwritten as i32)), - ), + None => future::err(deno_error::bad_resource()).boxed(), + Some(mut resource) => async move { + let nwritten = + tokio::io::AsyncWriteExt::write(&mut resource, &zero_copy) + .map_err(ErrBox::from) + .await?; + Ok(nwritten as i32) + } + .boxed(), } } } diff --git a/cli/flags.rs b/cli/flags.rs index a666ffe67a05c..e68023b32eb62 100644 --- a/cli/flags.rs +++ b/cli/flags.rs @@ -1,11 +1,11 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. +use crate::fs as deno_fs; use clap::App; use clap::AppSettings; use clap::Arg; use clap::ArgMatches; use clap::Shell; use clap::SubCommand; -use crate::fs as deno_fs; use deno::ModuleSpecifier; use log::Level; use std; @@ -59,7 +59,8 @@ fn add_run_args<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> { .use_delimiter(true) .require_equals(true) .help("Allow file system read access"), - ).arg( + ) + .arg( Arg::with_name("allow-write") .long("allow-write") .min_values(0) @@ -67,7 +68,8 @@ fn add_run_args<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> { .use_delimiter(true) .require_equals(true) .help("Allow file system write access"), - ).arg( + ) + .arg( Arg::with_name("allow-net") .long("allow-net") .min_values(0) @@ -75,28 +77,34 @@ fn add_run_args<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> { .use_delimiter(true) .require_equals(true) .help("Allow network access"), - ).arg( + ) + .arg( Arg::with_name("allow-env") .long("allow-env") .help("Allow environment access"), - ).arg( + ) + .arg( Arg::with_name("allow-run") .long("allow-run") .help("Allow running subprocesses"), - ).arg( + ) + .arg( Arg::with_name("allow-hrtime") .long("allow-hrtime") .help("Allow high resolution time measurement"), - ).arg( + ) + .arg( Arg::with_name("allow-all") .short("A") .long("allow-all") .help("Allow all permissions"), - ).arg( + ) + .arg( Arg::with_name("no-prompt") .long("no-prompt") .help("Do not use prompts"), - ).arg( + ) + .arg( Arg::with_name("importmap") .long("importmap") .value_name("FILE") @@ -105,7 +113,8 @@ fn add_run_args<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> { "Load import map file Specification: https://wicg.github.io/import-maps/ Examples: https://github.com/WICG/import-maps#the-import-map", - ).takes_value(true), + ) + .takes_value(true), ) } diff --git a/cli/fs.rs b/cli/fs.rs index 34e4d59f2d58a..8b8693fcda44f 100644 --- a/cli/fs.rs +++ b/cli/fs.rs @@ -69,7 +69,8 @@ pub fn make_temp_dir( let mut buf: PathBuf = match dir { Some(ref p) => p.to_path_buf(), None => std::env::temp_dir(), - }.join("_"); + } + .join("_"); let mut rng = rand::thread_rng(); loop { let unique = rng.gen::(); diff --git a/cli/global_timer.rs b/cli/global_timer.rs index d3ca52f460430..e5af50573b1d6 100644 --- a/cli/global_timer.rs +++ b/cli/global_timer.rs @@ -9,9 +9,11 @@ //! calls it) for an entire Isolate. This is what is implemented here. use crate::tokio_util::panic_on_error; -use futures::Future; +use futures::channel::oneshot; +use futures::future; +use futures::future::FutureExt; +use std::future::Future; use std::time::Instant; -use tokio::sync::oneshot; use tokio::timer::Delay; #[derive(Default)] @@ -33,7 +35,7 @@ impl GlobalTimer { pub fn new_timeout( &mut self, deadline: Instant, - ) -> impl Future { + ) -> impl Future> { if self.tx.is_some() { self.cancel(); } @@ -42,9 +44,9 @@ impl GlobalTimer { let (tx, rx) = oneshot::channel(); self.tx = Some(tx); - let delay = panic_on_error(Delay::new(deadline)); + let delay = Delay::new(deadline); let rx = panic_on_error(rx); - delay.select(rx).then(|_| Ok(())) + future::select(delay, rx).then(|_| future::ok(())) } } diff --git a/cli/http_body.rs b/cli/http_body.rs index 235463ff1c6ff..623d1eccf8c87 100644 --- a/cli/http_body.rs +++ b/cli/http_body.rs @@ -1,13 +1,15 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -use futures::Async; -use futures::Poll; +use futures_01::Async; use hyper::body::Payload; use hyper::Body; use hyper::Chunk; use std::cmp::min; use std::io; use std::io::Read; +use std::pin::Pin; +use std::task::Context; +use std::task::Poll; use tokio::io::AsyncRead; /// Wraps `hyper::Body` so that it can be exposed as an `AsyncRead` and integrated @@ -35,53 +37,58 @@ impl Read for HttpBody { } impl AsyncRead for HttpBody { - fn poll_read(&mut self, buf: &mut [u8]) -> Poll { - if let Some(chunk) = self.chunk.take() { + fn poll_read( + self: Pin<&mut Self>, + _cx: &mut Context, + buf: &mut [u8], + ) -> Poll> { + let inner = Pin::get_mut(self); + if let Some(chunk) = inner.chunk.take() { debug!( "HttpBody Fake Read buf {} chunk {} pos {}", buf.len(), chunk.len(), - self.pos + inner.pos ); - let n = min(buf.len(), chunk.len() - self.pos); + let n = min(buf.len(), chunk.len() - inner.pos); { - let rest = &chunk[self.pos..]; + let rest = &chunk[inner.pos..]; buf[..n].clone_from_slice(&rest[..n]); } - self.pos += n; - if self.pos == chunk.len() { - self.pos = 0; + inner.pos += n; + if inner.pos == chunk.len() { + inner.pos = 0; } else { - self.chunk = Some(chunk); + inner.chunk = Some(chunk); } - return Ok(Async::Ready(n)); + return Poll::Ready(Ok(n)); } else { - assert_eq!(self.pos, 0); + assert_eq!(inner.pos, 0); } - let p = self.body.poll_data(); + let p = inner.body.poll_data(); match p { - Err(e) => Err( + Err(e) => Poll::Ready(Err( // TODO Need to map hyper::Error into std::io::Error. io::Error::new(io::ErrorKind::Other, e), - ), - Ok(Async::NotReady) => Ok(Async::NotReady), + )), + Ok(Async::NotReady) => Poll::Pending, Ok(Async::Ready(maybe_chunk)) => match maybe_chunk { - None => Ok(Async::Ready(0)), + None => Poll::Ready(Ok(0)), Some(chunk) => { debug!( "HttpBody Real Read buf {} chunk {} pos {}", buf.len(), chunk.len(), - self.pos + inner.pos ); let n = min(buf.len(), chunk.len()); buf[..n].clone_from_slice(&chunk[..n]); if buf.len() < chunk.len() { - self.pos = n; - self.chunk = Some(chunk); + inner.pos = n; + inner.chunk = Some(chunk); } - Ok(Async::Ready(n)) + Poll::Ready(Ok(n)) } }, } diff --git a/cli/http_util.rs b/cli/http_util.rs index 16c4193051090..f8e1fba9c72d0 100644 --- a/cli/http_util.rs +++ b/cli/http_util.rs @@ -2,14 +2,17 @@ use crate::deno_error; use crate::deno_error::DenoError; use deno::ErrBox; -#[cfg(test)] -use futures::future::{loop_fn, Loop}; -use futures::{future, Future, Stream}; +use futures::compat::Future01CompatExt; +use futures::compat::Stream01CompatExt; +use futures::future; +use futures::future::TryFutureExt; +use futures::stream::TryStreamExt; use hyper; use hyper::client::{Client, HttpConnector}; use hyper::header::CONTENT_TYPE; use hyper::Uri; use hyper_rustls; +use std::future::Future; type Connector = hyper_rustls::HttpsConnector; @@ -60,6 +63,19 @@ fn resolve_uri_from_location(base_uri: &Uri, location: &str) -> Uri { #[cfg(test)] use crate::tokio_util; +#[cfg(test)] +use futures::future::FutureExt; +#[cfg(test)] +use hyper::Body; +#[cfg(test)] +use hyper::Response; +#[cfg(test)] +use std::pin::Pin; +#[cfg(test)] +use std::task::Context; +#[cfg(test)] +use std::task::Poll; + #[cfg(test)] /// Synchronously fetchs the given HTTP URL. Returns (content, media_type). pub fn fetch_sync_string( @@ -81,51 +97,60 @@ pub enum FetchOnceResult { /// yields Redirect(url). pub fn fetch_string_once( url: http::uri::Uri, -) -> impl Future { - type FetchAttempt = (Option, Option, Option); +) -> impl Future> { let client = get_client(); client .get(url.clone()) + .compat() .map_err(ErrBox::from) - .and_then( - move |response| -> Box< - dyn Future + Send, - > { - if response.status().is_redirection() { - let location_string = response - .headers() - .get("location") - .expect("url redirection should provide 'location' header") - .to_str() - .unwrap() - .to_string(); - debug!("Redirecting to {}...", &location_string); - let new_url = resolve_uri_from_location(&url, &location_string); - // Boxed trait object turns out to be the savior for 2+ types yielding same results. - return Box::new(future::ok(None).join3( - future::ok(None), - future::ok(Some(FetchOnceResult::Redirect(new_url))), - )); - } else if response.status().is_client_error() - || response.status().is_server_error() - { - return Box::new(future::err(DenoError::new( - deno_error::ErrorKind::Other, - format!("Import '{}' failed: {}", &url, response.status()), - ).into())); - } - let content_type = response + .and_then(move |response| { + if response.status().is_redirection() { + let location_string = response .headers() - .get(CONTENT_TYPE) - .map(|content_type| content_type.to_str().unwrap().to_owned()); - let body = response - .into_body() - .concat2() - .map(|body| String::from_utf8(body.to_vec()).ok()) - .map_err(ErrBox::from); - Box::new(body.join3(future::ok(content_type), future::ok(None))) - }, - ) + .get("location") + .expect("url redirection should provide 'location' header") + .to_str() + .unwrap() + .to_string(); + debug!("Redirecting to {}...", &location_string); + let new_url = resolve_uri_from_location(&url, &location_string); + // Boxed trait object turns out to be the savior for 2+ types yielding same results. + return future::try_join3( + future::Either::Left(future::ok(None)), + future::ok(None), + future::ok(Some(FetchOnceResult::Redirect(new_url))), + ); + } else if response.status().is_client_error() + || response.status().is_server_error() + { + return future::try_join3( + future::Either::Left(future::err( + DenoError::new( + deno_error::ErrorKind::Other, + format!("Import '{}' failed: {}", &url, response.status()), + ) + .into(), + )), + future::ok(None), + future::ok(None), + ); + } + let content_type = response + .headers() + .get(CONTENT_TYPE) + .map(|content_type| content_type.to_str().unwrap().to_owned()); + let body = response + .into_body() + .compat() + .try_concat() + .map_ok(|body| String::from_utf8(body.to_vec()).ok()) + .map_err(ErrBox::from); + future::try_join3( + future::Either::Right(body), + future::ok(content_type), + future::ok(None), + ) + }) .and_then(move |(maybe_code, maybe_content_type, maybe_redirect)| { if let Some(redirect) = maybe_redirect { future::ok(redirect) @@ -140,19 +165,40 @@ pub fn fetch_string_once( } #[cfg(test)] -/// Asynchronously fetchs the given HTTP URL. Returns (content, media_type). -pub fn fetch_string( - module_name: &str, -) -> impl Future { - let url = module_name.parse::().unwrap(); - let client = get_client(); - // TODO(kevinkassimo): consider set a max redirection counter - // to avoid bouncing between 2 or more urls - loop_fn((client, url), |(client, url)| { - client - .get(url.clone()) - .map_err(ErrBox::from) - .and_then(move |response| { +type FetchStringGetResult = Result, ErrBox>; +#[cfg(test)] +type FetchStringGetFuture = + dyn Future + Send + 'static; + +#[cfg(test)] +struct FetchStringFuture { + pub client: Client, + pub url: Uri, + pub maybe_get_future: Option>>, +} + +#[cfg(test)] +impl Future for FetchStringFuture { + type Output = FetchStringGetResult; + + fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { + let inner = Pin::get_mut(self); + + if inner.maybe_get_future.is_none() { + inner.maybe_get_future = Some( + inner + .client + .get(inner.url.clone()) + .compat() + .map_err(ErrBox::from) + .boxed(), + ); + } + + let mut get_future = inner.maybe_get_future.take().unwrap(); + + match get_future.poll_unpin(cx) { + Poll::Ready(Ok(response)) => { if response.status().is_redirection() { let location_string = response .headers() @@ -162,33 +208,63 @@ pub fn fetch_string( .unwrap() .to_string(); debug!("Redirecting to {}...", &location_string); - let new_url = resolve_uri_from_location(&url, &location_string); - return Ok(Loop::Continue((client, new_url))); + let new_url = resolve_uri_from_location(&inner.url, &location_string); + inner.url = new_url; + return Poll::Pending; } if !response.status().is_success() { - return Err( + return Poll::Ready(Err( DenoError::new( deno_error::ErrorKind::NotFound, "module not found".to_string(), - ).into(), - ); + ) + .into(), + )); } - Ok(Loop::Break(response)) - }) - }).and_then(|response| { - let content_type = response - .headers() - .get(CONTENT_TYPE) - .map(|content_type| content_type.to_str().unwrap().to_string()); - let body = response - .into_body() - .concat2() - .map(|body| String::from_utf8(body.to_vec()).unwrap()) - .map_err(ErrBox::from); - body.join(future::ok(content_type)) - }).and_then(|(body_string, maybe_content_type)| { - future::ok((body_string, maybe_content_type.unwrap())) - }) + Poll::Ready(Ok(response)) + } + Poll::Ready(Err(err)) => Poll::Ready(Err(err.into())), + Poll::Pending => { + inner.maybe_get_future = Some(get_future); + + Poll::Pending + } + } + } +} + +#[cfg(test)] +/// Asynchronously fetchs the given HTTP URL. Returns (content, media_type). +pub fn fetch_string( + module_name: &str, +) -> impl Future> { + let url = module_name.parse::().unwrap(); + let client = get_client(); + + let future = FetchStringFuture { + client, + url, + maybe_get_future: None, + }; + // TODO(kevinkassimo): consider set a max redirection counter + // to avoid bouncing between 2 or more urls + future + .and_then(|response| { + let content_type = response + .headers() + .get(CONTENT_TYPE) + .map(|content_type| content_type.to_str().unwrap().to_string()); + let body = response + .into_body() + .compat() + .try_concat() + .map_ok(|body| String::from_utf8(body.to_vec()).unwrap()) + .map_err(ErrBox::from); + future::try_join(body, future::ok(content_type)) + }) + .and_then(|(body_string, maybe_content_type)| { + future::ok((body_string, maybe_content_type.unwrap())) + }) } #[test] @@ -207,9 +283,10 @@ fn test_fetch_sync_string() { fn test_fetch_string() { // Relies on external http server. See tools/http_server.py tokio_util::init(|| { - let (p, m) = fetch_string("http://127.0.0.1:4545/package.json") - .wait() - .unwrap(); + let (p, m) = futures::executor::block_on(fetch_string( + "http://127.0.0.1:4545/package.json", + )) + .unwrap(); println!("package.json len {}", p.len()); assert!(p.len() > 1); assert!(m == "application/json") diff --git a/cli/import_map.rs b/cli/import_map.rs index abe9835f8cf85..7bfe7476c4f45 100644 --- a/cli/import_map.rs +++ b/cli/import_map.rs @@ -488,22 +488,20 @@ mod tests { // invalid schema: 'imports' is non-object for non_object in non_object_strings.to_vec() { - assert!( - ImportMap::from_json( - base_url, - &format!("{{\"imports\": {}}}", non_object), - ).is_err() - ); + assert!(ImportMap::from_json( + base_url, + &format!("{{\"imports\": {}}}", non_object), + ) + .is_err()); } // invalid schema: 'scopes' is non-object for non_object in non_object_strings.to_vec() { - assert!( - ImportMap::from_json( - base_url, - &format!("{{\"scopes\": {}}}", non_object), - ).is_err() - ); + assert!(ImportMap::from_json( + base_url, + &format!("{{\"scopes\": {}}}", non_object), + ) + .is_err()); } } @@ -756,11 +754,9 @@ mod tests { let import_map = ImportMap::from_json("https://base.example/path1/path2/path3", json_map) .unwrap(); - assert!( - import_map - .scopes - .contains_key("https://base.example/path1/path2/foo") - ); + assert!(import_map + .scopes + .contains_key("https://base.example/path1/path2/foo")); // Should work with ./, ../, and / prefixes.. let json_map = r#"{ @@ -773,16 +769,12 @@ mod tests { let import_map = ImportMap::from_json("https://base.example/path1/path2/path3", json_map) .unwrap(); - assert!( - import_map - .scopes - .contains_key("https://base.example/path1/path2/foo") - ); - assert!( - import_map - .scopes - .contains_key("https://base.example/path1/foo") - ); + assert!(import_map + .scopes + .contains_key("https://base.example/path1/path2/foo")); + assert!(import_map + .scopes + .contains_key("https://base.example/path1/foo")); assert!(import_map.scopes.contains_key("https://base.example/foo")); // Should work with /s, ?s, and #s.. @@ -794,11 +786,9 @@ mod tests { let import_map = ImportMap::from_json("https://base.example/path1/path2/path3", json_map) .unwrap(); - assert!( - import_map - .scopes - .contains_key("https://base.example/path1/path2/foo/bar?baz#qux") - ); + assert!(import_map + .scopes + .contains_key("https://base.example/path1/path2/foo/bar?baz#qux")); // Should work with an empty string scope key.. let json_map = r#"{ @@ -809,11 +799,9 @@ mod tests { let import_map = ImportMap::from_json("https://base.example/path1/path2/path3", json_map) .unwrap(); - assert!( - import_map - .scopes - .contains_key("https://base.example/path1/path2/path3") - ); + assert!(import_map + .scopes + .contains_key("https://base.example/path1/path2/path3")); // Should work with / suffixes.. let json_map = r#"{ @@ -828,21 +816,15 @@ mod tests { let import_map = ImportMap::from_json("https://base.example/path1/path2/path3", json_map) .unwrap(); - assert!( - import_map - .scopes - .contains_key("https://base.example/path1/path2/foo/") - ); - assert!( - import_map - .scopes - .contains_key("https://base.example/path1/path2/foo/") - ); - assert!( - import_map - .scopes - .contains_key("https://base.example/path1/foo/") - ); + assert!(import_map + .scopes + .contains_key("https://base.example/path1/path2/foo/")); + assert!(import_map + .scopes + .contains_key("https://base.example/path1/path2/foo/")); + assert!(import_map + .scopes + .contains_key("https://base.example/path1/foo/")); assert!(import_map.scopes.contains_key("https://base.example/foo/")); assert!(import_map.scopes.contains_key("https://base.example/foo//")); @@ -857,11 +839,9 @@ mod tests { let import_map = ImportMap::from_json("https://base.example/path1/path2/path3", json_map) .unwrap(); - assert!( - import_map - .scopes - .contains_key("https://base.example/path1/path2/foo//") - ); + assert!(import_map + .scopes + .contains_key("https://base.example/path1/path2/foo//")); assert_eq!(import_map.scopes.len(), 1); } @@ -909,11 +889,9 @@ mod tests { ImportMap::from_json("https://base.example/path1/path2/path3", json_map) .unwrap(); // tricky case! remember we have a base URL - assert!( - import_map - .scopes - .contains_key("https://base.example/path1/path2/example.org") - ); + assert!(import_map + .scopes + .contains_key("https://base.example/path1/path2/example.org")); assert!(import_map.scopes.contains_key("https://example.com///")); assert!(import_map.scopes.contains_key("https://example.net/")); assert!(import_map.scopes.contains_key("https://example.com/foo/")); @@ -1245,7 +1223,8 @@ mod tests { let import_map = ImportMap::from_json( "https://base.example/path1/path2/path3", &json_map.to_string(), - ).unwrap(); + ) + .unwrap(); assert!(import_map.imports.get("foo").unwrap().is_empty()); } @@ -1370,21 +1349,15 @@ mod tests { assert!(import_map.resolve("%2E/foo", referrer_url).is_err()); assert!(import_map.resolve("%2E%2Efoo", referrer_url).is_err()); assert!(import_map.resolve(".%2Efoo", referrer_url).is_err()); - assert!( - import_map - .resolve("https://ex ample.org", referrer_url) - .is_err() - ); - assert!( - import_map - .resolve("https://example.org:deno", referrer_url) - .is_err() - ); - assert!( - import_map - .resolve("https://[example.org]", referrer_url) - .is_err() - ); + assert!(import_map + .resolve("https://ex ample.org", referrer_url) + .is_err()); + assert!(import_map + .resolve("https://example.org:deno", referrer_url) + .is_err()); + assert!(import_map + .resolve("https://[example.org]", referrer_url) + .is_err()); } #[test] @@ -1512,11 +1485,9 @@ mod tests { ); // Should fail for attempting to get a submodule of something not declared with a trailing slash. - assert!( - import_map - .resolve("not-a-package/foo", referrer_url) - .is_err() - ); + assert!(import_map + .resolve("not-a-package/foo", referrer_url) + .is_err()); } #[test] @@ -1575,28 +1546,20 @@ mod tests { ); // Should fail for URLs that remap to empty arrays. - assert!( - import_map - .resolve("https://example.com/lib/no.mjs", referrer_url) - .is_err() - ); + assert!(import_map + .resolve("https://example.com/lib/no.mjs", referrer_url) + .is_err()); assert!(import_map.resolve("/lib/no.mjs", referrer_url).is_err()); assert!(import_map.resolve("../lib/no.mjs", referrer_url).is_err()); - assert!( - import_map - .resolve("https://example.com/app/dotrelative/no.mjs", referrer_url) - .is_err() - ); - assert!( - import_map - .resolve("/app/dotrelative/no.mjs", referrer_url) - .is_err() - ); - assert!( - import_map - .resolve("../app/dotrelative/no.mjs", referrer_url) - .is_err() - ); + assert!(import_map + .resolve("https://example.com/app/dotrelative/no.mjs", referrer_url) + .is_err()); + assert!(import_map + .resolve("/app/dotrelative/no.mjs", referrer_url) + .is_err()); + assert!(import_map + .resolve("../app/dotrelative/no.mjs", referrer_url) + .is_err()); // Should remap URLs that are just composed from / and .. assert_resolve( diff --git a/cli/main.rs b/cli/main.rs index 26bd810c8bc95..ca6f5fb7ee2e2 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -1,11 +1,11 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. +#![feature(async_await)] + #[macro_use] extern crate lazy_static; #[macro_use] extern crate log; #[macro_use] -extern crate futures; -#[macro_use] extern crate serde_json; extern crate clap; extern crate deno; @@ -43,7 +43,6 @@ pub mod source_maps; mod startup_data; pub mod state; mod tokio_util; -mod tokio_write; pub mod version; pub mod worker; @@ -57,12 +56,14 @@ use deno::ModuleSpecifier; use flags::DenoFlags; use flags::DenoSubcommand; use futures::future; -use futures::lazy; -use futures::Future; +use futures::future::lazy; +use futures::future::FutureExt; +use futures::future::TryFutureExt; use log::Level; use log::Metadata; use log::Record; use std::env; +use std::future::Future; static LOGGER: Logger = Logger; @@ -102,7 +103,7 @@ fn js_check(r: Result<(), ErrBox>) { pub fn print_file_info( worker: Worker, module_specifier: &ModuleSpecifier, -) -> impl Future { +) -> impl Future> { let state_ = worker.state.clone(); let module_specifier_ = module_specifier.clone(); @@ -131,7 +132,8 @@ pub fn print_file_info( debug!("compiler error exiting!"); eprintln!("\n{}", e.to_string()); std::process::exit(1); - }).and_then(move |compiled| { + }) + .and_then(move |compiled| { if out.media_type == msg::MediaType::TypeScript { println!( "{} {}", @@ -171,7 +173,7 @@ pub fn print_file_info( ansi::bold("deps:".to_string()), ); } - Ok(worker) + future::ok(worker) }) }) } @@ -217,24 +219,27 @@ fn fetch_or_info_command( let (mut worker, state) = create_worker_and_state(flags, argv); let main_module = state.main_module().unwrap(); - let main_future = lazy(move || { + let main_future = lazy(move |_cx| { // Setup runtime. js_check(worker.execute("denoMain()")); debug!("main_module {}", main_module); - + (worker, main_module) + }) + .then(move |(mut worker, main_module)| { worker .execute_mod_async(&main_module, true) .map_err(print_err_and_exit) .and_then(move |()| { if print_info { - future::Either::A(print_file_info(worker, &main_module)) + future::Either::Left(print_file_info(worker, &main_module)) } else { - future::Either::B(future::ok(worker)) + future::Either::Right(future::ok(worker)) } - }).and_then(|worker| { + }) + .and_then(|worker| { worker.then(|result| { js_check(result); - Ok(()) + future::ok(()) }) }) }); @@ -254,15 +259,20 @@ fn eval_command(flags: DenoFlags, argv: Vec) { &state.argv[1] ); - let main_future = lazy(move || { + let main_future = lazy(move |_cx| { js_check(worker.execute("denoMain()")); // ATM imports in `deno eval` are not allowed // TODO Support ES modules once Worker supports evaluating anonymous modules. js_check(worker.execute(&js_source)); - worker.then(|result| { - js_check(result); - Ok(()) - }) + worker + }) + .then(move |worker| { + worker + .then(|result| { + js_check(result); + future::ok(()) + }) + .map_err(|(err, _worker): (ErrBox, Worker)| print_err_and_exit(err)) }); tokio_util::run(main_future); } @@ -277,15 +287,19 @@ fn xeval_command(flags: DenoFlags, argv: Vec) { &xeval_replvar, &state.argv[1] ); - let main_future = lazy(move || { + let main_future = lazy(move |_cx| { // Setup runtime. js_check(worker.execute(&xeval_source)); js_check(worker.execute("denoMain()")); + worker + }) + .then(move |worker| { worker .then(|result| { js_check(result); - Ok(()) - }).map_err(print_err_and_exit) + future::ok(()) + }) + .map_err(print_err_and_exit) }); tokio_util::run(main_future); } @@ -304,9 +318,10 @@ fn bundle_command(flags: DenoFlags, argv: Vec) { debug!("diagnostics returned, exiting!"); eprintln!(""); print_err_and_exit(err); - }).and_then(move |_| { + }) + .and_then(move |_| { debug!(">>>>> bundle_async END"); - Ok(()) + future::ok(()) }); tokio_util::run(bundle_future); } @@ -315,14 +330,18 @@ fn run_repl(flags: DenoFlags, argv: Vec) { let (mut worker, _state) = create_worker_and_state(flags, argv); // REPL situation. - let main_future = lazy(move || { + let main_future = lazy(move |_cx| { // Setup runtime. js_check(worker.execute("denoMain()")); + worker + }) + .then(move |worker| { worker .then(|result| { js_check(result); - Ok(()) - }).map_err(|(err, _worker): (ErrBox, Worker)| print_err_and_exit(err)) + future::ok(()) + }) + .map_err(|(err, _worker): (ErrBox, Worker)| print_err_and_exit(err)) }); tokio_util::run(main_future); } @@ -332,20 +351,23 @@ fn run_script(flags: DenoFlags, argv: Vec) { let main_module = state.main_module().unwrap(); // Normal situation of executing a module. - let main_future = lazy(move || { + let main_future = lazy(move |_cx| { // Setup runtime. js_check(worker.execute("denoMain()")); debug!("main_module {}", main_module); - + (worker, main_module) + }) + .then(|(mut worker, main_module)| { worker .execute_mod_async(&main_module, false) .and_then(move |()| { js_check(worker.execute("window.dispatchEvent(new Event('load'))")); worker.then(|result| { js_check(result); - Ok(()) + future::ok(()) }) - }).map_err(print_err_and_exit) + }) + .map_err(print_err_and_exit) }); tokio_util::run(main_future); } diff --git a/cli/msg.rs b/cli/msg.rs index 0aaf368e10b66..51726b5726c02 100644 --- a/cli/msg.rs +++ b/cli/msg.rs @@ -1,9 +1,6 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. #![allow(dead_code)] -#![cfg_attr( - feature = "cargo-clippy", - allow(clippy::all, clippy::pedantic) -)] +#![cfg_attr(feature = "cargo-clippy", allow(clippy::all, clippy::pedantic))] use crate::state; use flatbuffers; use std::sync::atomic::Ordering; diff --git a/cli/ops.rs b/cli/ops.rs index d4bc94f75b717..7e82f3c8bec9c 100644 --- a/cli/ops.rs +++ b/cli/ops.rs @@ -1,5 +1,4 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -use atty; use crate::ansi; use crate::deno_dir::SourceFileFetcher; use crate::deno_error; @@ -23,34 +22,38 @@ use crate::signal::kill; use crate::startup_data; use crate::state::ThreadSafeState; use crate::tokio_util; -use crate::tokio_write; use crate::version; use crate::worker::Worker; +use atty; use deno::Buf; use deno::CoreOp; use deno::ErrBox; use deno::Loader; use deno::ModuleSpecifier; use deno::Op; -use deno::OpResult; use deno::PinnedBuf; +use deno::ResultOpResult; use flatbuffers::FlatBufferBuilder; -use futures; -use futures::Async; -use futures::Poll; -use futures::Sink; -use futures::Stream; +use futures::compat::Future01CompatExt; +use futures::future; +use futures::future::FutureExt; +use futures::future::TryFutureExt; +use futures::sink::SinkExt; +use futures::stream::StreamExt; use hyper; -use hyper::rt::Future; use log; use rand::{thread_rng, Rng}; use remove_dir_all::remove_dir_all; use std; use std::convert::From; use std::fs; +use std::future::Future; use std::net::Shutdown; use std::path::PathBuf; +use std::pin::Pin; use std::process::Command; +use std::task::Context; +use std::task::Poll; use std::time::{Duration, Instant, UNIX_EPOCH}; use tokio; use tokio::net::TcpListener; @@ -65,11 +68,13 @@ use std::os::unix::fs::PermissionsExt; #[cfg(unix)] use std::os::unix::process::ExitStatusExt; -type CliOpResult = OpResult; +type CliOpResult = ResultOpResult; -type CliDispatchFn = - fn(state: &ThreadSafeState, base: &msg::Base<'_>, data: Option) - -> CliOpResult; +type CliDispatchFn = fn( + state: &ThreadSafeState, + base: &msg::Base<'_>, + data: Option, +) -> CliOpResult; pub type OpSelector = fn(inner_type: msg::Any) -> Option; @@ -131,43 +136,46 @@ pub fn dispatch_all_legacy( Op::Sync(buf) } Ok(Op::Async(fut)) => { - let result_fut = Box::new( - fut.or_else(move |err: ErrBox| -> Result { - debug!("op err {}", err); - // No matter whether we got an Err or Ok, we want a serialized message to - // send back. So transform the DenoError into a Buf. - let builder = &mut FlatBufferBuilder::new(); - let errmsg_offset = builder.create_string(&format!("{}", err)); - Ok(serialize_response( - cmd_id, - builder, - msg::BaseArgs { - error: Some(errmsg_offset), - error_kind: err.kind(), - ..Default::default() - }, - )) - }).and_then(move |buf: Buf| -> Result { - // Handle empty responses. For sync responses we just want - // to send null. For async we want to send a small message - // with the cmd_id. - let buf = if buf.len() > 0 { - buf - } else { + let result_fut = fut.then(move |res| { + match res { + Err(err) => { + debug!("op err {}", err); + // No matter whether we got an Err or Ok, we want a serialized message to + // send back. So transform the DenoError into a Buf. let builder = &mut FlatBufferBuilder::new(); - serialize_response( + let errmsg_offset = builder.create_string(&format!("{}", err)); + future::ready(serialize_response( cmd_id, builder, msg::BaseArgs { + error: Some(errmsg_offset), + error_kind: err.kind(), ..Default::default() }, - ) - }; - state.metrics_op_completed(buf.len()); - Ok(buf) - }).map_err(|err| panic!("unexpected error {:?}", err)), - ); - Op::Async(result_fut) + )) + } + Ok(buf) => { + // Handle empty responses. For sync responses we just want + // to send null. For async we want to send a small message + // with the cmd_id. + let buf = if buf.len() > 0 { + buf + } else { + let builder = &mut FlatBufferBuilder::new(); + serialize_response( + cmd_id, + builder, + msg::BaseArgs { + ..Default::default() + }, + ) + }; + state.metrics_op_completed(buf.len()); + future::ready(buf) + } + } + }); + Op::Async(result_fut.boxed()) } Err(err) => { debug!("op err {}", err); @@ -452,7 +460,7 @@ fn serialize_response( #[inline] pub fn ok_future(buf: Buf) -> CliOpResult { - Ok(Op::Async(Box::new(futures::future::ok(buf)))) + Ok(Op::Async(future::ok(buf).boxed())) } #[inline] @@ -514,7 +522,7 @@ fn op_fetch_source_file( data: Some(data_off), }; let inner = msg::FetchSourceFileRes::create(builder, &msg_args); - Ok(serialize_response( + future::ok(serialize_response( cmd_id, builder, msg::BaseArgs { @@ -578,20 +586,23 @@ fn op_global_timer( let deadline = Instant::now() + Duration::from_millis(val as u64); let f = t.new_timeout(deadline); - Ok(Op::Async(Box::new(f.then(move |_| { - let builder = &mut FlatBufferBuilder::new(); - let inner = - msg::GlobalTimerRes::create(builder, &msg::GlobalTimerResArgs {}); - Ok(serialize_response( - cmd_id, - builder, - msg::BaseArgs { - inner: Some(inner.as_union_value()), - inner_type: msg::Any::GlobalTimerRes, - ..Default::default() - }, - )) - })))) + Ok(Op::Async( + f.then(move |_| { + let builder = &mut FlatBufferBuilder::new(); + let inner = + msg::GlobalTimerRes::create(builder, &msg::GlobalTimerResArgs {}); + future::ok(serialize_response( + cmd_id, + builder, + msg::BaseArgs { + inner: Some(inner.as_union_value()), + inner_type: msg::Any::GlobalTimerRes, + ..Default::default() + }, + )) + }) + .boxed(), + )) } fn op_set_env( @@ -715,67 +726,66 @@ fn op_fetch( let client = http_util::get_client(); debug!("Before fetch {}", url); - let future = client - .request(req) - .map_err(ErrBox::from) - .and_then(move |res| { - let builder = &mut FlatBufferBuilder::new(); - let header_off = msg_util::serialize_http_response(builder, &res); - let body = res.into_body(); - let body_resource = resources::add_hyper_body(body); - let inner = msg::FetchRes::create( - builder, - &msg::FetchResArgs { - header: Some(header_off), - body_rid: body_resource.rid, - }, - ); + let future = + client + .request(req) + .compat() + .map_err(ErrBox::from) + .and_then(move |res| { + let builder = &mut FlatBufferBuilder::new(); + let header_off = msg_util::serialize_http_response(builder, &res); + let body = res.into_body(); + let body_resource = resources::add_hyper_body(body); + let inner = msg::FetchRes::create( + builder, + &msg::FetchResArgs { + header: Some(header_off), + body_rid: body_resource.rid, + }, + ); - Ok(serialize_response( - cmd_id, - builder, - msg::BaseArgs { - inner: Some(inner.as_union_value()), - inner_type: msg::Any::FetchRes, - ..Default::default() - }, - )) - }); + future::ok(serialize_response( + cmd_id, + builder, + msg::BaseArgs { + inner: Some(inner.as_union_value()), + inner_type: msg::Any::FetchRes, + ..Default::default() + }, + )) + }); if base.sync() { - let result_buf = future.wait()?; + let result_buf = futures::executor::block_on(future)?; Ok(Op::Sync(result_buf)) } else { - Ok(Op::Async(Box::new(future))) + Ok(Op::Async(future.boxed())) } } // This is just type conversion. Implement From trait? // See https://github.com/tokio-rs/tokio/blob/ffd73a64e7ec497622b7f939e38017afe7124dc4/tokio-fs/src/lib.rs#L76-L85 -fn convert_blocking(f: F) -> Poll +fn convert_blocking(f: F) -> Poll> where - F: FnOnce() -> Result, + F: FnOnce() -> Result + Unpin, { - use futures::Async::*; match tokio_threadpool::blocking(f) { - Ok(Ready(Ok(v))) => Ok(v.into()), - Ok(Ready(Err(err))) => Err(err), - Ok(NotReady) => Ok(NotReady), - Err(err) => panic!("blocking error {}", err), + Poll::Ready(Ok(v)) => Poll::Ready(v), + Poll::Pending => Poll::Pending, + Poll::Ready(Err(err)) => panic!("blocking error {}", err), } } fn blocking(is_sync: bool, f: F) -> CliOpResult where - F: 'static + Send + FnOnce() -> Result, + F: 'static + Send + FnOnce() -> Result + Unpin, { if is_sync { let result_buf = f()?; Ok(Op::Sync(result_buf)) } else { - Ok(Op::Async(Box::new(futures::sync::oneshot::spawn( + Ok(Op::Async(tokio_util::spawn_on_default( tokio_util::poll_fn(move || convert_blocking(f)), - &tokio_executor::DefaultExecutor::current(), - )))) + ))) } } @@ -961,7 +971,7 @@ fn op_open( let builder = &mut FlatBufferBuilder::new(); let inner = msg::OpenRes::create(builder, &msg::OpenResArgs { rid: resource.rid }); - Ok(serialize_response( + future::ok(serialize_response( cmd_id, builder, msg::BaseArgs { @@ -973,10 +983,10 @@ fn op_open( }, ); if base.sync() { - let buf = op.wait()?; + let buf = futures::executor::block_on(op)?; Ok(Op::Sync(buf)) } else { - Ok(Op::Async(Box::new(op))) + Ok(Op::Async(op.boxed())) } } @@ -1047,33 +1057,36 @@ fn op_read( match resources::lookup(rid) { None => Err(deno_error::bad_resource()), - Some(resource) => { - let op = tokio::io::read(resource, data.unwrap()) - .map_err(ErrBox::from) - .and_then(move |(_resource, _buf, nread)| { - let builder = &mut FlatBufferBuilder::new(); - let inner = msg::ReadRes::create( - builder, - &msg::ReadResArgs { - nread: nread as u32, - eof: nread == 0, - }, - ); - Ok(serialize_response( - cmd_id, - builder, - msg::BaseArgs { - inner: Some(inner.as_union_value()), - inner_type: msg::Any::ReadRes, - ..Default::default() - }, - )) - }); + Some(mut resource) => { + let op = async move { + let mut data = data.unwrap(); + let nread = tokio::io::AsyncReadExt::read(&mut resource, &mut data) + .map_err(ErrBox::from) + .await?; + + let builder = &mut FlatBufferBuilder::new(); + let inner = msg::ReadRes::create( + builder, + &msg::ReadResArgs { + nread: nread as u32, + eof: nread == 0, + }, + ); + Ok(serialize_response( + cmd_id, + builder, + msg::BaseArgs { + inner: Some(inner.as_union_value()), + inner_type: msg::Any::ReadRes, + ..Default::default() + }, + )) + }; if base.sync() { - let buf = op.wait()?; + let buf = futures::executor::block_on(op)?; Ok(Op::Sync(buf)) } else { - Ok(Op::Async(Box::new(op))) + Ok(Op::Async(op.boxed())) } } } @@ -1090,32 +1103,34 @@ fn op_write( match resources::lookup(rid) { None => Err(deno_error::bad_resource()), - Some(resource) => { - let op = tokio_write::write(resource, data.unwrap()) - .map_err(ErrBox::from) - .and_then(move |(_resource, _buf, nwritten)| { - let builder = &mut FlatBufferBuilder::new(); - let inner = msg::WriteRes::create( - builder, - &msg::WriteResArgs { - nbyte: nwritten as u32, - }, - ); - Ok(serialize_response( - cmd_id, - builder, - msg::BaseArgs { - inner: Some(inner.as_union_value()), - inner_type: msg::Any::WriteRes, - ..Default::default() - }, - )) - }); + Some(mut resource) => { + let op = async move { + let data = data.unwrap(); + let nwritten = tokio::io::AsyncWriteExt::write(&mut resource, &data) + .map_err(ErrBox::from) + .await?; + let builder = &mut FlatBufferBuilder::new(); + let inner = msg::WriteRes::create( + builder, + &msg::WriteResArgs { + nbyte: nwritten as u32, + }, + ); + Ok(serialize_response( + cmd_id, + builder, + msg::BaseArgs { + inner: Some(inner.as_union_value()), + inner_type: msg::Any::WriteRes, + ..Default::default() + }, + )) + }; if base.sync() { - let buf = op.wait()?; + let buf = futures::executor::block_on(op)?; Ok(Op::Sync(buf)) } else { - Ok(Op::Async(Box::new(op))) + Ok(Op::Async(op.boxed())) } } } @@ -1136,12 +1151,12 @@ fn op_seek( None => Err(deno_error::bad_resource()), Some(resource) => { let op = resources::seek(resource, offset, whence) - .and_then(move |_| Ok(empty_buf())); + .and_then(move |_| future::ok(empty_buf())); if base.sync() { - let buf = op.wait()?; + let buf = futures::executor::block_on(op)?; Ok(Op::Sync(buf)) } else { - Ok(Op::Async(Box::new(op))) + Ok(Op::Async(op.boxed())) } } } @@ -1333,7 +1348,8 @@ fn op_read_dir( has_mode: cfg!(target_family = "unix"), }, ) - }).collect(); + }) + .collect(); let entries = builder.create_vector(&entries); let inner = msg::ReadDirRes::create( @@ -1578,7 +1594,7 @@ fn op_listen( state.check_net(&address)?; - let addr = resolve_addr(address).wait()?; + let addr = futures::executor::block_on(resolve_addr(address))?; let listener = TcpListener::bind(&addr)?; let resource = resources::add_tcp_listener(listener); @@ -1636,13 +1652,13 @@ fn op_accept( let op = tokio_util::accept(server_resource) .map_err(ErrBox::from) .and_then(move |(tcp_stream, _socket_addr)| { - new_conn(cmd_id, tcp_stream) + future::ready(new_conn(cmd_id, tcp_stream)) }); if base.sync() { - let buf = op.wait()?; + let buf = futures::executor::block_on(op)?; Ok(Op::Sync(buf)) } else { - Ok(Op::Async(Box::new(op))) + Ok(Op::Async(op.boxed())) } } } @@ -1665,13 +1681,13 @@ fn op_dial( let op = resolve_addr(address).and_then(move |addr| { TcpStream::connect(&addr) .map_err(ErrBox::from) - .and_then(move |tcp_stream| new_conn(cmd_id, tcp_stream)) + .and_then(move |tcp_stream| future::ready(new_conn(cmd_id, tcp_stream))) }); if base.sync() { - let buf = op.wait()?; + let buf = futures::executor::block_on(op)?; Ok(Op::Sync(buf)) } else { - Ok(Op::Async(Box::new(op))) + Ok(Op::Async(op.boxed())) } } @@ -1750,7 +1766,8 @@ fn op_resources( repr: Some(repr), }, ) - }).collect(); + }) + .collect(); let resources = builder.create_vector(&res); let inner = msg::ResourcesRes::create( @@ -1877,9 +1894,9 @@ fn op_run_status( state.check_run()?; - let future = resources::child_status(rid)?; + let op = resources::child_status(rid)?; - let future = future.and_then(move |run_status| { + let op = op.and_then(move |run_status| { let code = run_status.code(); #[cfg(unix)] @@ -1901,7 +1918,7 @@ fn op_run_status( exit_signal: signal.unwrap_or(-1), }, ); - Ok(serialize_response( + future::ok(serialize_response( cmd_id, builder, msg::BaseArgs { @@ -1912,10 +1929,10 @@ fn op_run_status( )) }); if base.sync() { - let buf = future.wait()?; + let buf = futures::executor::block_on(op)?; Ok(Op::Sync(buf)) } else { - Ok(Op::Async(Box::new(future))) + Ok(Op::Async(op.boxed())) } } @@ -1924,14 +1941,21 @@ struct GetMessageFuture { } impl Future for GetMessageFuture { - type Item = Option; - type Error = (); + type Output = Result; - fn poll(&mut self) -> Result, Self::Error> { + fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { let mut wc = self.state.worker_channels.lock().unwrap(); - wc.1 - .poll() - .map_err(|err| panic!("worker_channel recv err {:?}", err)) + match wc.1.poll_next_unpin(cx) { + Poll::Ready(None) => Poll::Ready(Err( + DenoError::new( + deno_error::ErrorKind::Other, + "Worker stream ended".to_string(), + ) + .into(), + )), + Poll::Ready(Some(v)) => Poll::Ready(Ok(v)), + Poll::Pending => Poll::Pending, + } } } @@ -1950,17 +1974,16 @@ fn op_worker_get_message( let op = GetMessageFuture { state: state.clone(), }; - let op = op.map_err(move |_| -> ErrBox { unimplemented!() }); - let op = op.and_then(move |maybe_buf| -> Result { + let op = op.and_then(move |buf| { debug!("op_worker_get_message"); let builder = &mut FlatBufferBuilder::new(); - let data = maybe_buf.as_ref().map(|buf| builder.create_vector(buf)); + let data = Some(builder.create_vector(&buf)); let inner = msg::WorkerGetMessageRes::create( builder, &msg::WorkerGetMessageResArgs { data }, ); - Ok(serialize_response( + future::ok(serialize_response( cmd_id, builder, msg::BaseArgs { @@ -1970,7 +1993,7 @@ fn op_worker_get_message( }, )) }); - Ok(Op::Async(Box::new(op))) + Ok(Op::Async(op.boxed())) } /// Post message to host as guest worker @@ -1982,12 +2005,11 @@ fn op_worker_post_message( let cmd_id = base.cmd_id(); let d = Vec::from(data.unwrap().as_ref()).into_boxed_slice(); - let tx = { + let mut tx = { let wc = state.worker_channels.lock().unwrap(); wc.0.clone() }; - tx.send(d) - .wait() + futures::executor::block_on(tx.send(d)) .map_err(|e| DenoError::new(ErrorKind::Other, e.to_string()))?; let builder = &mut FlatBufferBuilder::new(); @@ -2034,13 +2056,13 @@ fn op_create_worker( .execute_mod_async(&module_specifier, false) .and_then(move |()| { let mut workers_tl = parent_state.workers.lock().unwrap(); - workers_tl.insert(rid, worker.shared()); + workers_tl.insert(rid, worker); let builder = &mut FlatBufferBuilder::new(); let msg_inner = msg::CreateWorkerRes::create( builder, &msg::CreateWorkerResArgs { rid }, ); - Ok(serialize_response( + future::ok(serialize_response( cmd_id, builder, msg::BaseArgs { @@ -2051,7 +2073,7 @@ fn op_create_worker( )) }); - let result = op.wait()?; + let result = tokio_util::block_on(op)?; Ok(Op::Sync(result)) } @@ -2070,24 +2092,24 @@ fn op_host_get_worker_closed( let rid = inner.rid(); let state = state.clone(); - let shared_worker_future = { - let workers_tl = state.workers.lock().unwrap(); - let worker = workers_tl.get(&rid).unwrap(); - worker.clone() + let worker = { + let mut workers_tl = state.workers.lock().unwrap(); + let worker = workers_tl.remove(&rid).unwrap(); + worker }; - let op = Box::new(shared_worker_future.then(move |_result| { + let op = worker.then(move |_result| { let builder = &mut FlatBufferBuilder::new(); - Ok(serialize_response( + future::ok(serialize_response( cmd_id, builder, msg::BaseArgs { ..Default::default() }, )) - })); - Ok(Op::Async(Box::new(op))) + }); + Ok(Op::Async(op.boxed())) } /// Get message from guest worker as host @@ -2105,16 +2127,15 @@ fn op_host_get_message( let rid = inner.rid(); let op = resources::get_message_from_worker(rid); - let op = op.map_err(move |_| -> ErrBox { unimplemented!() }); - let op = op.and_then(move |maybe_buf| -> Result { + let op = op.and_then(move |maybe_buf| { let builder = &mut FlatBufferBuilder::new(); - let data = maybe_buf.as_ref().map(|buf| builder.create_vector(buf)); + let data = maybe_buf.map(|buf| builder.create_vector(&buf)); let msg_inner = msg::HostGetMessageRes::create( builder, &msg::HostGetMessageResArgs { data }, ); - Ok(serialize_response( + future::ok(serialize_response( cmd_id, builder, msg::BaseArgs { @@ -2124,7 +2145,7 @@ fn op_host_get_message( }, )) }); - Ok(Op::Async(Box::new(op))) + Ok(Op::Async(op.boxed())) } /// Post message to guest worker as host @@ -2139,8 +2160,7 @@ fn op_host_post_message( let d = Vec::from(data.unwrap().as_ref()).into_boxed_slice(); - resources::post_message_to_worker(rid, d) - .wait() + tokio_util::block_on(resources::post_message_to_worker(rid, d)) .map_err(|e| DenoError::new(ErrorKind::Other, e.to_string()))?; let builder = &mut FlatBufferBuilder::new(); diff --git a/cli/permissions.rs b/cli/permissions.rs index 8549e97795bde..9774d92c03ecd 100644 --- a/cli/permissions.rs +++ b/cli/permissions.rs @@ -1,8 +1,8 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -use ansi_term::Style; -use atty; use crate::deno_error::permission_denied; use crate::flags::DenoFlags; +use ansi_term::Style; +use atty; use deno::ErrBox; use log; use std::collections::HashSet; diff --git a/cli/repl.rs b/cli/repl.rs index a253e4435d664..7e72b9b108482 100644 --- a/cli/repl.rs +++ b/cli/repl.rs @@ -68,7 +68,9 @@ impl Repl { self .editor .load_history(&self.history_file.to_str().unwrap()) - .map_err(|e| debug!("Unable to load history file: {:?} {}", self.history_file, e)) + .map_err(|e| { + debug!("Unable to load history file: {:?} {}", self.history_file, e) + }) // ignore this error (e.g. it occurs on first load) .unwrap_or(()) } @@ -91,7 +93,8 @@ impl Repl { .map(|line| { self.editor.add_history_entry(line.clone()); line - }).map_err(ErrBox::from) + }) + .map_err(ErrBox::from) // Forward error to TS side for processing } } diff --git a/cli/resolve_addr.rs b/cli/resolve_addr.rs index b783444d86dfa..2ee8470aeef4b 100644 --- a/cli/resolve_addr.rs +++ b/cli/resolve_addr.rs @@ -1,11 +1,12 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. use crate::deno_error; use deno::ErrBox; -use futures::Async; -use futures::Future; -use futures::Poll; +use std::future::Future; use std::net::SocketAddr; use std::net::ToSocketAddrs; +use std::pin::Pin; +use std::task::Context; +use std::task::Poll; /// Go-style network address parsing. Returns a future. /// Examples: @@ -25,23 +26,22 @@ pub struct ResolveAddrFuture { } impl Future for ResolveAddrFuture { - type Item = SocketAddr; - type Error = ErrBox; + type Output = Result; - fn poll(&mut self) -> Poll { + fn poll(self: Pin<&mut Self>, _cx: &mut Context) -> Poll { // The implementation of this is not actually async at the moment, // however we intend to use async DNS resolution in the future and // so we expose this as a future instead of Result. match split(&self.address) { - None => Err(deno_error::invalid_address_syntax()), + None => Poll::Ready(Err(deno_error::invalid_address_syntax())), Some(addr_port_pair) => { // I absolutely despise the .to_socket_addrs() API. let r = addr_port_pair.to_socket_addrs().map_err(ErrBox::from); - r.and_then(|mut iter| match iter.next() { - Some(a) => Ok(Async::Ready(a)), + Poll::Ready(r.and_then(|mut iter| match iter.next() { + Some(a) => Ok(a), None => panic!("There should be at least one result"), - }) + })) } } } @@ -106,7 +106,8 @@ mod tests { fn resolve_addr1() { let expected = SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::new(127, 0, 0, 1), 80)); - let actual = resolve_addr("127.0.0.1:80").wait().unwrap(); + let actual = + futures::executor::block_on(resolve_addr("127.0.0.1:80")).unwrap(); assert_eq!(actual, expected); } @@ -114,7 +115,8 @@ mod tests { fn resolve_addr3() { let expected = SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::new(192, 0, 2, 1), 25)); - let actual = resolve_addr("192.0.2.1:25").wait().unwrap(); + let actual = + futures::executor::block_on(resolve_addr("192.0.2.1:25")).unwrap(); assert_eq!(actual, expected); } @@ -126,7 +128,8 @@ mod tests { 0, 0, )); - let actual = resolve_addr("[2001:db8::1]:8080").wait().unwrap(); + let actual = + futures::executor::block_on(resolve_addr("[2001:db8::1]:8080")).unwrap(); assert_eq!(actual, expected); } } diff --git a/cli/resources.rs b/cli/resources.rs index 9ef12a4293de6..e6bcc834a42ed 100644 --- a/cli/resources.rs +++ b/cli/resources.rs @@ -17,24 +17,29 @@ use crate::state::WorkerChannels; use deno::Buf; use deno::ErrBox; -use futures; -use futures::Future; -use futures::Poll; -use futures::Sink; -use futures::Stream; +use futures::channel::mpsc; +use futures::future; +use futures::future::FutureExt; +use futures::io::AsyncRead as FutAsyncRead; +use futures::io::AsyncWrite as FutAsyncWrite; +use futures::stream::StreamExt; +use futures::task::AtomicWaker; use hyper; use std; use std::collections::HashMap; +use std::future::Future; use std::io::{Error, Read, Seek, SeekFrom, Write}; use std::net::{Shutdown, SocketAddr}; +use std::pin::Pin; use std::process::ExitStatus; use std::sync::atomic::AtomicUsize; use std::sync::atomic::Ordering; use std::sync::{Arc, Mutex}; +use std::task::Context; +use std::task::Poll; use tokio; use tokio::io::{AsyncRead, AsyncWrite}; use tokio::net::TcpStream; -use tokio::sync::mpsc; use tokio_process; pub type ResourceId = u32; // Sometimes referred to RID. @@ -87,7 +92,7 @@ enum Repr { // this pending task could be notified and die. // Currently TcpListener itself does not take care of this issue. // See: https://github.com/tokio-rs/tokio/issues/846 - TcpListener(tokio::net::TcpListener, Option), + TcpListener(tokio::net::TcpListener, Option), TcpStream(tokio::net::TcpStream), HttpBody(HttpBody), Repl(Arc>), @@ -155,16 +160,19 @@ pub struct Resource { impl Resource { // TODO Should it return a Resource instead of net::TcpStream? - pub fn poll_accept(&mut self) -> Poll<(TcpStream, SocketAddr), Error> { + pub fn poll_accept( + &mut self, + cx: &mut Context, + ) -> Poll> { let mut table = RESOURCE_TABLE.lock().unwrap(); let maybe_repr = table.get_mut(&self.rid); match maybe_repr { - None => Err(std::io::Error::new( + None => Poll::Ready(Err(std::io::Error::new( std::io::ErrorKind::Other, "Listener has been closed", - )), + ))), Some(repr) => match repr { - Repr::TcpListener(ref mut s, _) => s.poll_accept(), + Repr::TcpListener(ref mut s, _) => s.poll_accept(cx), _ => panic!("Cannot accept"), }, } @@ -172,7 +180,7 @@ impl Resource { /// Track the current task (for TcpListener resource). /// Throws an error if another task is already tracked. - pub fn track_task(&mut self) -> Result<(), std::io::Error> { + pub fn track_task(&mut self, cx: &mut Context) -> Result<(), std::io::Error> { let mut table = RESOURCE_TABLE.lock().unwrap(); // Only track if is TcpListener. if let Some(Repr::TcpListener(_, t)) = table.get_mut(&self.rid) { @@ -186,7 +194,9 @@ impl Resource { "Another accept task is ongoing", )); } - t.replace(futures::task::current()); + let waker = AtomicWaker::new(); + waker.register(cx.waker()); + t.replace(waker); } Ok(()) } @@ -211,7 +221,7 @@ impl Resource { // If TcpListener, we must kill all pending accepts! if let Repr::TcpListener(_, Some(t)) = r { // Call notify on the tracked task, so that they would error out. - t.notify(); + t.wake(); } } @@ -237,18 +247,22 @@ impl Read for Resource { } impl AsyncRead for Resource { - fn poll_read(&mut self, buf: &mut [u8]) -> Poll { + fn poll_read( + self: Pin<&mut Self>, + cx: &mut Context, + buf: &mut [u8], + ) -> Poll> { let mut table = RESOURCE_TABLE.lock().unwrap(); let maybe_repr = table.get_mut(&self.rid); match maybe_repr { None => panic!("bad rid"), Some(repr) => match repr { - Repr::FsFile(ref mut f) => f.poll_read(buf), - Repr::Stdin(ref mut f) => f.poll_read(buf), - Repr::TcpStream(ref mut f) => f.poll_read(buf), - Repr::HttpBody(ref mut f) => f.poll_read(buf), - Repr::ChildStdout(ref mut f) => f.poll_read(buf), - Repr::ChildStderr(ref mut f) => f.poll_read(buf), + Repr::FsFile(ref mut f) => Pin::new(f).poll_read(cx, buf), + Repr::Stdin(ref mut f) => Pin::new(f).poll_read(cx, buf), + Repr::TcpStream(ref mut f) => Pin::new(f).poll_read(cx, buf), + Repr::HttpBody(ref mut f) => Pin::new(f).poll_read(cx, buf), + Repr::ChildStdout(ref mut f) => Pin::new(f).poll_read(cx, buf), + Repr::ChildStderr(ref mut f) => Pin::new(f).poll_read(cx, buf), _ => panic!("Cannot read"), }, } @@ -266,24 +280,62 @@ impl Write for Resource { } impl AsyncWrite for Resource { - fn poll_write(&mut self, buf: &[u8]) -> Poll { + fn poll_write( + self: Pin<&mut Self>, + cx: &mut Context, + buf: &[u8], + ) -> Poll> { let mut table = RESOURCE_TABLE.lock().unwrap(); let maybe_repr = table.get_mut(&self.rid); match maybe_repr { None => panic!("bad rid"), Some(repr) => match repr { - Repr::FsFile(ref mut f) => f.poll_write(buf), - Repr::Stdout(ref mut f) => f.poll_write(buf), - Repr::Stderr(ref mut f) => f.poll_write(buf), - Repr::TcpStream(ref mut f) => f.poll_write(buf), - Repr::ChildStdin(ref mut f) => f.poll_write(buf), + Repr::FsFile(ref mut f) => Pin::new(f).poll_write(cx, buf), + Repr::Stdout(ref mut f) => Pin::new(f).poll_write(cx, buf), + Repr::Stderr(ref mut f) => Pin::new(f).poll_write(cx, buf), + Repr::TcpStream(ref mut f) => Pin::new(f).poll_write(cx, buf), + Repr::ChildStdin(ref mut f) => Pin::new(f).poll_write(cx, buf), _ => panic!("Cannot write"), }, } } - fn shutdown(&mut self) -> futures::Poll<(), std::io::Error> { - unimplemented!() + fn poll_flush( + self: Pin<&mut Self>, + cx: &mut Context, + ) -> Poll> { + let mut table = RESOURCE_TABLE.lock().unwrap(); + let maybe_repr = table.get_mut(&self.rid); + match maybe_repr { + None => panic!("bad rid"), + Some(repr) => match repr { + Repr::FsFile(ref mut f) => Pin::new(f).poll_flush(cx), + Repr::Stdout(ref mut f) => Pin::new(f).poll_flush(cx), + Repr::Stderr(ref mut f) => Pin::new(f).poll_flush(cx), + Repr::TcpStream(ref mut f) => Pin::new(f).poll_flush(cx), + // Repr::ChildStdin(ref mut f) => Pin::new(f).poll_flush(cx), + _ => panic!("Cannot write"), + }, + } + } + + fn poll_shutdown( + self: Pin<&mut Self>, + cx: &mut Context, + ) -> Poll> { + let mut table = RESOURCE_TABLE.lock().unwrap(); + let maybe_repr = table.get_mut(&self.rid); + match maybe_repr { + None => panic!("bad rid"), + Some(repr) => match repr { + Repr::FsFile(ref mut f) => Pin::new(f).poll_shutdown(cx), + Repr::Stdout(ref mut f) => Pin::new(f).poll_shutdown(cx), + Repr::Stderr(ref mut f) => Pin::new(f).poll_shutdown(cx), + Repr::TcpStream(ref mut f) => Pin::new(f).poll_shutdown(cx), + // Repr::ChildStdin(ref mut f) => Pin::new(f).poll_shutdown(cx), + _ => panic!("Cannot write"), + }, + } } } @@ -342,17 +394,65 @@ pub fn add_worker(wc: WorkerChannels) -> Resource { Resource { rid } } +// type PostMessageSendFuture = dyn Future> + Send + 'static; + +struct PostMessageFuture { + pub sender: Option>, + pub buf: Option, +} + +impl Future for PostMessageFuture { + type Output = Result<(), ErrBox>; + + fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { + let inner = Pin::get_mut(self); + + let mut sender = inner.sender.take().unwrap(); + + let mut sender_pin = Pin::new(&mut sender); + + match sender_pin.poll_ready(cx) { + Poll::Ready(Err(err)) => Poll::Ready(Err( + deno_error::DenoError::new( + deno_error::ErrorKind::Other, + format!("Post message error {}", err), + ) + .into(), + )), + Poll::Ready(Ok(_)) => { + Poll::Ready(sender_pin.start_send(inner.buf.take().unwrap()).map_err( + |err| { + deno_error::DenoError::new( + deno_error::ErrorKind::Other, + format!("Post message error {}", err), + ) + .into() + }, + )) + } + Poll::Pending => { + inner.sender = Some(sender); + + Poll::Pending + } + } + } +} + /// Post message to worker as a host or privilged overlord pub fn post_message_to_worker( rid: ResourceId, buf: Buf, -) -> futures::sink::Send> { +) -> impl Future> { let mut table = RESOURCE_TABLE.lock().unwrap(); let maybe_repr = table.get_mut(&rid); match maybe_repr { - Some(Repr::Worker(ref mut wc)) => { - // unwrap here is incorrect, but doing it anyway - wc.0.clone().send(buf) + Some(Repr::Worker(ref wc)) => { + let sender = wc.0.clone(); + PostMessageFuture { + sender: Some(sender), + buf: Some(buf), + } } _ => panic!("bad resource"), // futures::future::err(bad_resource()).into(), } @@ -364,15 +464,18 @@ pub struct WorkerReceiver { // Invert the dumbness that tokio_process causes by making Child itself a future. impl Future for WorkerReceiver { - type Item = Option; - type Error = ErrBox; + type Output = Result, ErrBox>; - fn poll(&mut self) -> Poll, ErrBox> { + fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { let mut table = RESOURCE_TABLE.lock().unwrap(); let maybe_repr = table.get_mut(&self.rid); match maybe_repr { - Some(Repr::Worker(ref mut wc)) => wc.1.poll().map_err(ErrBox::from), - _ => Err(bad_resource()), + Some(Repr::Worker(ref mut wc)) => match wc.1.poll_next_unpin(cx) { + Poll::Ready(None) => Poll::Ready(Ok(None)), + Poll::Ready(Some(v)) => Poll::Ready(Ok(Some(v))), + Poll::Pending => Poll::Pending, + }, + _ => Poll::Ready(Err(bad_resource())), } } } @@ -381,29 +484,6 @@ pub fn get_message_from_worker(rid: ResourceId) -> WorkerReceiver { WorkerReceiver { rid } } -pub struct WorkerReceiverStream { - rid: ResourceId, -} - -// Invert the dumbness that tokio_process causes by making Child itself a future. -impl Stream for WorkerReceiverStream { - type Item = Buf; - type Error = ErrBox; - - fn poll(&mut self) -> Poll, ErrBox> { - let mut table = RESOURCE_TABLE.lock().unwrap(); - let maybe_repr = table.get_mut(&self.rid); - match maybe_repr { - Some(Repr::Worker(ref mut wc)) => wc.1.poll().map_err(ErrBox::from), - _ => Err(bad_resource()), - } - } -} - -pub fn get_message_stream_from_worker(rid: ResourceId) -> WorkerReceiverStream { - WorkerReceiverStream { rid } -} - pub struct ChildResources { pub child_rid: ResourceId, pub stdin_rid: Option, @@ -456,15 +536,16 @@ pub struct ChildStatus { // Invert the dumbness that tokio_process causes by making Child itself a future. impl Future for ChildStatus { - type Item = ExitStatus; - type Error = ErrBox; + type Output = Result; - fn poll(&mut self) -> Poll { + fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { let mut table = RESOURCE_TABLE.lock().unwrap(); let maybe_repr = table.get_mut(&self.rid); match maybe_repr { - Some(Repr::Child(ref mut child)) => child.poll().map_err(ErrBox::from), - _ => Err(bad_resource()), + Some(Repr::Child(ref mut child)) => { + child.poll_unpin(cx).map_err(ErrBox::from) + } + _ => Poll::Ready(Err(bad_resource())), } } } @@ -532,27 +613,30 @@ pub fn seek( resource: Resource, offset: i32, whence: u32, -) -> Box + Send> { +) -> Pin> + Send>> { // Translate seek mode to Rust repr. let seek_from = match whence { 0 => SeekFrom::Start(offset as u64), 1 => SeekFrom::Current(i64::from(offset)), 2 => SeekFrom::End(i64::from(offset)), _ => { - return Box::new(futures::future::err( + return futures::future::err( deno_error::DenoError::new( deno_error::ErrorKind::InvalidSeekMode, format!("Invalid seek mode: {}", whence), - ).into(), - )); + ) + .into(), + ) + .boxed(); } }; match get_file(resource.rid) { - Ok(mut file) => Box::new(futures::future::lazy(move || { + Ok(mut file) => future::lazy(move |_cx| { let result = file.seek(seek_from).map(|_| {}).map_err(ErrBox::from); - futures::future::result(result) - })), - Err(err) => Box::new(futures::future::err(err)), + result + }) + .boxed(), + Err(err) => futures::future::err(err).boxed(), } } diff --git a/cli/shell.rs b/cli/shell.rs index 9a66efe715099..aaf29b4e06f09 100644 --- a/cli/shell.rs +++ b/cli/shell.rs @@ -342,18 +342,18 @@ impl ShellOut { None => write!(stream, " ")?, } } /* - ShellOut::Write(ref mut w) => { - if justified { - write!(w, "{:>12}", status)?; - } else { - write!(w, "{}", status)?; - } - match message { - Some(message) => writeln!(w, " {}", message)?, - None => write!(w, " ")?, + ShellOut::Write(ref mut w) => { + if justified { + write!(w, "{:>12}", status)?; + } else { + write!(w, "{}", status)?; + } + match message { + Some(message) => writeln!(w, " {}", message)?, + None => write!(w, " ")?, + } } - } - */ + */ } Ok(()) } @@ -479,12 +479,10 @@ mod imp { } } -#[cfg( - any( - all(unix, not(any(target_os = "linux", target_os = "macos"))), - windows - ) -)] +#[cfg(any( + all(unix, not(any(target_os = "linux", target_os = "macos"))), + windows +))] fn default_err_erase_line(shell: &mut Shell) { if let Some(max_width) = imp::stderr_width() { let blank = " ".repeat(max_width); diff --git a/cli/source_maps.rs b/cli/source_maps.rs index 6b453d883cd8d..6561dba70e7f0 100644 --- a/cli/source_maps.rs +++ b/cli/source_maps.rs @@ -78,13 +78,15 @@ fn builtin_source_map(script_name: &str) -> Option> { include_bytes!(concat!( env!("GN_OUT_DIR"), "/gen/cli/bundle/main.js.map" - )).to_vec(), + )) + .to_vec(), ), "gen/cli/bundle/compiler.js" => Some( include_bytes!(concat!( env!("GN_OUT_DIR"), "/gen/cli/bundle/compiler.js.map" - )).to_vec(), + )) + .to_vec(), ), _ => None, } diff --git a/cli/state.rs b/cli/state.rs index 2e490484ace36..93227f8fd3d65 100644 --- a/cli/state.rs +++ b/cli/state.rs @@ -18,24 +18,26 @@ use deno::ErrBox; use deno::Loader; use deno::ModuleSpecifier; use deno::PinnedBuf; -use futures::future::Shared; -use futures::Future; +use futures::channel::mpsc; +use futures::future::FutureExt; +use futures::future::TryFutureExt; use rand::rngs::StdRng; use rand::SeedableRng; use std; use std::collections::HashMap; use std::env; +use std::future::Future; use std::ops::Deref; +use std::pin::Pin; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Arc; use std::sync::Mutex; use std::time::Instant; -use tokio::sync::mpsc as async_mpsc; -pub type WorkerSender = async_mpsc::Sender; -pub type WorkerReceiver = async_mpsc::Receiver; +pub type WorkerSender = mpsc::Sender; +pub type WorkerReceiver = mpsc::Receiver; pub type WorkerChannels = (WorkerSender, WorkerReceiver); -pub type UserWorkerTable = HashMap>; +pub type UserWorkerTable = HashMap; #[derive(Default)] pub struct Metrics { @@ -105,7 +107,7 @@ impl ThreadSafeState { pub fn fetch_source_file_and_maybe_compile_async( state: &ThreadSafeState, module_specifier: &ModuleSpecifier, -) -> impl Future { +) -> impl Future> { let state_ = state.clone(); state_ @@ -147,18 +149,16 @@ impl Loader for ThreadSafeState { fn load( &self, module_specifier: &ModuleSpecifier, - ) -> Box { + ) -> Pin> { self.metrics.resolve_count.fetch_add(1, Ordering::SeqCst); - Box::new( - fetch_source_file_and_maybe_compile_async(self, module_specifier).map( - |source_file| deno::SourceCodeInfo { - // Real module name, might be different from initial specifier - // due to redirections. - code: source_file.js_source(), - module_name: source_file.url.to_string(), - }, - ), - ) + fetch_source_file_and_maybe_compile_async(self, module_specifier) + .map_ok(|source_file| deno::SourceCodeInfo { + // Real module name, might be different from initial specifier + // due to redirections. + code: source_file.js_source(), + module_name: source_file.url.to_string(), + }) + .boxed() } } @@ -171,8 +171,8 @@ impl ThreadSafeState { ) -> Self { let custom_root = env::var("DENO_DIR").map(String::into).ok(); - let (worker_in_tx, worker_in_rx) = async_mpsc::channel::(1); - let (worker_out_tx, worker_out_rx) = async_mpsc::channel::(1); + let (worker_in_tx, worker_in_rx) = mpsc::channel::(1); + let (worker_out_tx, worker_out_rx) = mpsc::channel::(1); let internal_channels = (worker_out_tx, worker_in_rx); let external_channels = (worker_in_tx, worker_out_rx); let resource = resources::add_worker(external_channels); @@ -182,7 +182,8 @@ impl ThreadSafeState { progress.clone(), !flags.reload, flags.no_fetch, - ).unwrap(); + ) + .unwrap(); let main_module: Option = if argv_rest.len() <= 1 { None diff --git a/cli/tokio_util.rs b/cli/tokio_util.rs index 4c4b36d5e3674..1200fa09b610c 100644 --- a/cli/tokio_util.rs +++ b/cli/tokio_util.rs @@ -1,11 +1,14 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. use crate::resources::Resource; use futures; -use futures::Future; -use futures::Poll; +use futures::future::FutureExt; +use std::future::Future; use std::io; use std::mem; use std::net::SocketAddr; +use std::pin::Pin; +use std::task::Context; +use std::task::Poll; use tokio; use tokio::net::TcpStream; use tokio::runtime; @@ -19,11 +22,11 @@ pub fn create_threadpool_runtime() -> tokio::runtime::Runtime { pub fn run(future: F) where - F: Future + Send + 'static, + F: Future> + Send + 'static, { // tokio::runtime::current_thread::run(future) let rt = create_threadpool_runtime(); - rt.block_on_all(future).unwrap(); + rt.block_on(future).unwrap(); } /// THIS IS A HACK AND SHOULD BE AVOIDED. @@ -34,7 +37,7 @@ where /// main runtime. pub fn block_on(future: F) -> Result where - F: Send + 'static + Future, + F: Send + 'static + Future>, R: Send + 'static, E: Send + 'static, { @@ -43,13 +46,37 @@ where let (sender, receiver) = channel(); // Create a new runtime to evaluate the future asynchronously. thread::spawn(move || { - let mut rt = create_threadpool_runtime(); + let rt = create_threadpool_runtime(); let r = rt.block_on(future); sender.send(r).unwrap(); }); receiver.recv().unwrap() } +pub fn spawn_on_default( + future: F, +) -> Pin> + Send>> +where + F: Send + 'static + Future> + Unpin, + R: Send + 'static, + E: Send + 'static, +{ + use futures::channel::oneshot::channel; + use tokio::executor::Executor; + let (sender, receiver) = channel(); + tokio::executor::DefaultExecutor::current() + .spawn( + future + .then(|result| { + assert!(sender.send(result).is_ok()); + futures::future::ready(()) + }) + .boxed(), + ) + .unwrap(); + receiver.map(|result| result.unwrap()).boxed() +} + // Set the default executor so we can use tokio::spawn(). It's difficult to // pass around mut references to the runtime, so using with_default is // preferable. Ideally Tokio would provide this function. @@ -86,35 +113,35 @@ pub struct Accept { state: AcceptState, } impl Future for Accept { - type Item = (TcpStream, SocketAddr); - type Error = io::Error; + type Output = Result<(TcpStream, SocketAddr), io::Error>; - fn poll(&mut self) -> Poll { - let (stream, addr) = match self.state { + fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { + let inner = Pin::get_mut(self); + let (stream, addr) = match inner.state { // Similar to try_ready!, but also track/untrack accept task // in TcpListener resource. // In this way, when the listener is closed, the task can be // notified to error out (instead of stuck forever). - AcceptState::Pending(ref mut r) => match r.poll_accept() { - Ok(futures::prelude::Async::Ready(t)) => { + AcceptState::Pending(ref mut r) => match r.poll_accept(cx) { + Poll::Ready(Ok(t)) => { r.untrack_task(); t } - Ok(futures::prelude::Async::NotReady) => { + Poll::Pending => { // Would error out if another accept task is being tracked. - r.track_task()?; - return Ok(futures::prelude::Async::NotReady); + r.track_task(cx)?; + return Poll::Pending; } - Err(e) => { + Poll::Ready(Err(e)) => { r.untrack_task(); - return Err(e); + return Poll::Ready(Err(e)); } }, AcceptState::Empty => panic!("poll Accept after it's done"), }; - match mem::replace(&mut self.state, AcceptState::Empty) { - AcceptState::Pending(_) => Ok((stream, addr).into()), + match mem::replace(&mut inner.state, AcceptState::Empty) { + AcceptState::Pending(_) => Poll::Ready(Ok((stream, addr).into())), AcceptState::Empty => panic!("invalid internal state"), } } @@ -125,7 +152,7 @@ impl Future for Accept { /// Therefore, we created our version of `poll_fn`. pub fn poll_fn(f: F) -> PollFn where - F: FnOnce() -> Poll, + F: FnOnce() -> Poll> + Unpin, { PollFn { inner: Some(f) } } @@ -136,21 +163,24 @@ pub struct PollFn { impl Future for PollFn where - F: FnOnce() -> Poll, + F: FnOnce() -> Poll> + Unpin, { - type Item = T; - type Error = E; + type Output = Result; - fn poll(&mut self) -> Poll { - let f = self.inner.take().expect("Inner fn has been taken."); + fn poll(self: Pin<&mut Self>, _cx: &mut Context) -> Poll { + let inner = Pin::get_mut(self); + let f = inner.inner.take().expect("Inner fn has been taken."); f() } } -pub fn panic_on_error(f: F) -> impl Future +pub fn panic_on_error(f: F) -> impl Future where - F: Future, + F: Future>, E: std::fmt::Debug, { - f.map_err(|err| panic!("Future got unexpected error: {:?}", err)) + f.map(|result| match result { + Err(err) => panic!("Future got unexpected error: {:?}", err), + Ok(v) => v, + }) } diff --git a/cli/tokio_write.rs b/cli/tokio_write.rs deleted file mode 100644 index 945de375d82a8..0000000000000 --- a/cli/tokio_write.rs +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -// TODO Submit this file upstream into tokio-io/src/io/write.rs -use std::io; -use std::mem; - -use futures::{Future, Poll}; -use tokio::io::AsyncWrite; - -/// A future used to write some data to a stream. -/// -/// This is created by the [`write`] top-level method. -/// -/// [`write`]: fn.write.html -#[derive(Debug)] -pub struct Write { - state: State, -} - -#[derive(Debug)] -enum State { - Pending { a: A, buf: T }, - Empty, -} - -/// Creates a future that will write some of the buffer `buf` to -/// the stream `a` provided. -/// -/// Any error which happens during writing will cause both the stream and the -/// buffer to get destroyed. -pub fn write(a: A, buf: T) -> Write -where - A: AsyncWrite, - T: AsRef<[u8]>, -{ - Write { - state: State::Pending { a, buf }, - } -} - -impl Future for Write -where - A: AsyncWrite, - T: AsRef<[u8]>, -{ - type Item = (A, T, usize); - type Error = io::Error; - - fn poll(&mut self) -> Poll<(A, T, usize), io::Error> { - let nwritten = match self.state { - State::Pending { - ref mut a, - ref mut buf, - } => try_ready!(a.poll_write(buf.as_ref())), - State::Empty => panic!("poll a Read after it's done"), - }; - - match mem::replace(&mut self.state, State::Empty) { - State::Pending { a, buf } => Ok((a, buf, nwritten).into()), - State::Empty => panic!("invalid internal state"), - } - } -} diff --git a/cli/worker.rs b/cli/worker.rs index 71a42dd8df277..edeffba35d1bb 100644 --- a/cli/worker.rs +++ b/cli/worker.rs @@ -1,15 +1,20 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. use crate::fmt_errors::JSError; use crate::state::ThreadSafeState; -use crate::tokio_util; use deno; use deno::ErrBox; use deno::ModuleSpecifier; use deno::StartupData; -use futures::Async; -use futures::Future; +use futures::executor::block_on; +use futures::future; +use futures::future::FutureExt; +use futures::future::TryFutureExt; +use std::future::Future; +use std::pin::Pin; use std::sync::Arc; use std::sync::Mutex; +use std::task::Context; +use std::task::Poll; /// Wraps deno::Isolate to provide source maps, ops for the CLI, and /// high-level module loading @@ -61,7 +66,7 @@ impl Worker { &mut self, module_specifier: &ModuleSpecifier, is_prefetch: bool, - ) -> impl Future { + ) -> impl Future> { let worker = self.clone(); let loader = self.state.clone(); let isolate = self.isolate.clone(); @@ -72,13 +77,13 @@ impl Worker { isolate, modules, ); - recursive_load.and_then(move |id| -> Result<(), ErrBox> { + recursive_load.and_then(move |id| { worker.state.progress.done(); if is_prefetch { - Ok(()) + future::ok(()) } else { let mut isolate = worker.isolate.lock().unwrap(); - isolate.mod_evaluate(id) + future::ready(isolate.mod_evaluate(id)) } }) } @@ -89,17 +94,16 @@ impl Worker { module_specifier: &ModuleSpecifier, is_prefetch: bool, ) -> Result<(), ErrBox> { - tokio_util::block_on(self.execute_mod_async(module_specifier, is_prefetch)) + block_on(self.execute_mod_async(module_specifier, is_prefetch)) } } impl Future for Worker { - type Item = (); - type Error = ErrBox; + type Output = Result<(), ErrBox>; - fn poll(&mut self) -> Result, ErrBox> { + fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { let mut isolate = self.isolate.lock().unwrap(); - isolate.poll() + isolate.poll_unpin(cx) } } @@ -128,15 +132,18 @@ mod tests { Progress::new(), ); let state_ = state.clone(); - tokio_util::run(lazy(move || { - let mut worker = - Worker::new("TEST".to_string(), StartupData::None, state); - let result = worker.execute_mod(&module_specifier, false); - if let Err(err) = result { - eprintln!("execute_mod err {:?}", err); - } - tokio_util::panic_on_error(worker) - })); + tokio_util::run( + lazy(move |_cx| { + let mut worker = + Worker::new("TEST".to_string(), StartupData::None, state); + let result = worker.execute_mod(&module_specifier, false); + if let Err(err) = result { + eprintln!("execute_mod err {:?}", err); + } + worker + }) + .then(|worker| tokio_util::panic_on_error(worker).map(|r| Ok(r))), + ); let metrics = &state_.metrics; assert_eq!(metrics.resolve_count.load(Ordering::SeqCst), 2); @@ -156,15 +163,18 @@ mod tests { Progress::new(), ); let state_ = state.clone(); - tokio_util::run(lazy(move || { - let mut worker = - Worker::new("TEST".to_string(), StartupData::None, state); - let result = worker.execute_mod(&module_specifier, false); - if let Err(err) = result { - eprintln!("execute_mod err {:?}", err); - } - tokio_util::panic_on_error(worker) - })); + tokio_util::run( + lazy(move |_cx| { + let mut worker = + Worker::new("TEST".to_string(), StartupData::None, state); + let result = worker.execute_mod(&module_specifier, false); + if let Err(err) = result { + eprintln!("execute_mod err {:?}", err); + } + worker + }) + .then(|worker| tokio_util::panic_on_error(worker).map(|r| Ok(r))), + ); let metrics = &state_.metrics; assert_eq!(metrics.resolve_count.load(Ordering::SeqCst), 2); @@ -182,19 +192,22 @@ mod tests { let state = ThreadSafeState::new(flags, argv, op_selector_std, Progress::new()); let state_ = state.clone(); - tokio_util::run(lazy(move || { - let mut worker = Worker::new( - "TEST".to_string(), - startup_data::deno_isolate_init(), - state, - ); - worker.execute("denoMain()").unwrap(); - let result = worker.execute_mod(&module_specifier, false); - if let Err(err) = result { - eprintln!("execute_mod err {:?}", err); - } - tokio_util::panic_on_error(worker) - })); + tokio_util::run( + lazy(move |_cx| { + let mut worker = Worker::new( + "TEST".to_string(), + startup_data::deno_isolate_init(), + state, + ); + worker.execute("denoMain()").unwrap(); + let result = worker.execute_mod(&module_specifier, false); + if let Err(err) = result { + eprintln!("execute_mod err {:?}", err); + } + worker + }) + .then(|worker| tokio_util::panic_on_error(worker).map(|r| Ok(r))), + ); let metrics = &state_.metrics; assert_eq!(metrics.resolve_count.load(Ordering::SeqCst), 3); @@ -236,22 +249,29 @@ mod tests { let resource = worker.state.resource.clone(); let resource_ = resource.clone(); - tokio::spawn(lazy(move || { - worker.then(move |r| -> Result<(), ()> { - resource_.close(); - r.unwrap(); - Ok(()) - }) - })); + tokio::spawn( + worker + .then(move |r| { + resource_.close(); + r.unwrap(); + future::ok(()) + }) + .boxed() + .compat(), + ); let msg = json!("hi").to_string().into_boxed_str().into_boxed_bytes(); - let r = resources::post_message_to_worker(resource.rid, msg).wait(); + let r = futures::executor::block_on(resources::post_message_to_worker( + resource.rid, + msg, + )); assert!(r.is_ok()); - let maybe_msg = resources::get_message_from_worker(resource.rid) - .wait() - .unwrap(); + let maybe_msg_result = + tokio_util::block_on(resources::get_message_from_worker(resource.rid)); + assert!(maybe_msg_result.is_ok()); + let maybe_msg = maybe_msg_result.unwrap(); assert!(maybe_msg.is_some()); // Check if message received is [1, 2, 3] in json assert_eq!(*maybe_msg.unwrap(), *b"[1,2,3]"); @@ -260,7 +280,10 @@ mod tests { .to_string() .into_boxed_str() .into_boxed_bytes(); - let r = resources::post_message_to_worker(resource.rid, msg).wait(); + let r = futures::executor::block_on(resources::post_message_to_worker( + resource.rid, + msg, + )); assert!(r.is_ok()); }) } @@ -276,25 +299,28 @@ mod tests { let resource = worker.state.resource.clone(); let rid = resource.rid; - let worker_future = worker - .then(move |r| -> Result<(), ()> { - resource.close(); - println!("workers.rs after resource close"); - r.unwrap(); - Ok(()) - }).shared(); + let (sender, receiver) = futures::channel::oneshot::channel(); - let worker_future_ = worker_future.clone(); - tokio::spawn(lazy(move || worker_future_.then(|_| Ok(())))); + let worker_future = worker.then(move |r| { + resource.close(); + println!("workers.rs after resource close"); + r.unwrap(); + sender.send(()).unwrap(); + future::ok(()) + }); + + tokio::spawn(worker_future.boxed().compat()); assert_eq!(resources::get_type(rid), Some("worker".to_string())); let msg = json!("hi").to_string().into_boxed_str().into_boxed_bytes(); - let r = resources::post_message_to_worker(rid, msg).wait(); + let r = futures::executor::block_on(resources::post_message_to_worker( + rid, msg, + )); assert!(r.is_ok()); debug!("rid {:?}", rid); - worker_future.wait().unwrap(); + futures::executor::block_on(receiver).unwrap(); assert_eq!(resources::get_type(rid), None); }) } @@ -306,7 +332,9 @@ mod tests { let mut worker = create_test_worker(); let module_specifier = ModuleSpecifier::resolve_url_or_path("does-not-exist").unwrap(); - let result = worker.execute_mod_async(&module_specifier, false).wait(); + let result = futures::executor::block_on( + worker.execute_mod_async(&module_specifier, false), + ); assert!(result.is_err()); }) } @@ -319,7 +347,9 @@ mod tests { let mut worker = create_test_worker(); let module_specifier = ModuleSpecifier::resolve_url_or_path("./tests/002_hello.ts").unwrap(); - let result = worker.execute_mod_async(&module_specifier, false).wait(); + let result = futures::executor::block_on( + worker.execute_mod_async(&module_specifier, false), + ); assert!(result.is_ok()); }) } diff --git a/core/BUILD.gn b/core/BUILD.gn index 0f1eba8cae0eb..5872caf29f4b3 100644 --- a/core/BUILD.gn +++ b/core/BUILD.gn @@ -18,9 +18,17 @@ group("deno_core_deps") { ] } +main_extern = [ + { + label = "//build_extra/rust:futures_preview" + crate_name = "futures" + crate_type = "rlib" + crate_version = "0.3.0-alpha.17" + }, +] + # deno does not depend on flatbuffers nor tokio. main_extern_rlib = [ - "futures", "libc", "serde_json", "log", @@ -32,6 +40,7 @@ rust_rlib("deno") { deps = [ ":deno_core_deps", ] + extern = main_extern extern_rlib = main_extern_rlib } @@ -40,6 +49,7 @@ rust_test("deno_core_test") { deps = [ ":deno_core_deps", ] + extern = main_extern extern_rlib = main_extern_rlib } @@ -49,9 +59,14 @@ http_bench_extern = [ crate_name = "deno" crate_type = "rlib" }, + { + label = "//build_extra/rust:futures_preview" + crate_name = "futures" + crate_type = "rlib" + crate_version = "0.3.0-alpha.17" + }, ] http_bench_extern_rlib = [ - "futures", "lazy_static", "libc", "log", diff --git a/core/Cargo.toml b/core/Cargo.toml index 6faac632aa054..f4390ae033213 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -18,7 +18,7 @@ name = "snapshot_creator" path = "snapshot_creator.rs" [dependencies] -futures = "0.1.27" +futures-preview = { version = "0.3.0-alpha.17", features = ["compat"] } lazy_static = "1.3.0" libc = "0.2.58" log = "0.4.6" diff --git a/core/examples/http_bench.rs b/core/examples/http_bench.rs index 98f11bc4d1557..8db9d2e3efc85 100644 --- a/core/examples/http_bench.rs +++ b/core/examples/http_bench.rs @@ -13,14 +13,22 @@ extern crate log; extern crate lazy_static; use deno::*; +use futures::executor::block_on; use futures::future::lazy; +use futures::future::Future; +use futures::future::FutureExt; +use futures::future::TryFutureExt; +use futures::task::Poll; use std::collections::HashMap; use std::env; use std::net::SocketAddr; +use std::pin::Pin; use std::sync::atomic::AtomicUsize; use std::sync::atomic::Ordering; use std::sync::Mutex; -use tokio::prelude::*; +use tokio::io::AsyncRead; +use tokio::io::AsyncWrite; +use tokio::prelude::Async; static LOGGER: Logger = Logger; struct Logger; @@ -109,7 +117,7 @@ fn test_record_from() { // TODO test From<&[u8]> for Record } -pub type HttpBenchOp = dyn Future + Send; +pub type HttpBenchOp = dyn Future> + Send; fn dispatch(control: &[u8], zero_copy_buf: Option) -> CoreOp { let record = Record::from(control); @@ -144,50 +152,29 @@ fn dispatch(control: &[u8], zero_copy_buf: Option) -> CoreOp { let mut record_a = record.clone(); let mut record_b = record.clone(); - let fut = Box::new( - http_bench_op - .and_then(move |result| { - record_a.result = result; - Ok(record_a) - }).or_else(|err| -> Result { + let fut = http_bench_op + .then(move |result| match result { + Ok(res) => { + record_a.result = res; + futures::future::ready(record_a) + } + Err(err) => { eprintln!("unexpected err {}", err); record_b.result = -1; - Ok(record_b) - }).then(|result| -> Result { - let record = result.unwrap(); - Ok(record.into()) - }), - ); + futures::future::ready(record_b) + } + }) + .then(|record| futures::future::ready(record.into())) + .boxed(); if is_sync { - Op::Sync(fut.wait().unwrap()) + Op::Sync(block_on(fut)) } else { Op::Async(fut) } } fn main() { - let main_future = lazy(move || { - // TODO currently isolate.execute() must be run inside tokio, hence the - // lazy(). It would be nice to not have that contraint. Probably requires - // using v8::MicrotasksPolicy::kExplicit - - let js_source = include_str!("http_bench.js"); - - let startup_data = StartupData::Script(Script { - source: js_source, - filename: "http_bench.js", - }); - - let mut isolate = deno::Isolate::new(startup_data, false); - isolate.set_dispatch(dispatch); - - isolate.then(|r| { - js_check(r); - Ok(()) - }) - }); - let args: Vec = env::args().collect(); // NOTE: `--help` arg will display V8 help and exit let args = deno::v8_set_flags(args); @@ -199,12 +186,29 @@ fn main() { log::LevelFilter::Warn }); + let js_source = include_str!("http_bench.js"); + + let startup_data = StartupData::Script(Script { + source: js_source, + filename: "http_bench.js", + }); + + let mut isolate = deno::Isolate::new(startup_data, false); + isolate.set_dispatch(dispatch); + + let main_future = isolate + .then(|r| { + js_check(r); + futures::future::ok(()) + }) + .boxed(); + if args.iter().any(|a| a == "--multi-thread") { println!("multi-thread"); - tokio::run(main_future); + tokio::run(main_future.compat()); } else { println!("single-thread"); - tokio::runtime::current_thread::run(main_future); + tokio::runtime::current_thread::run(main_future.compat()); } } @@ -224,90 +228,111 @@ fn new_rid() -> i32 { rid as i32 } -fn op_accept(listener_rid: i32) -> Box { +fn op_accept(listener_rid: i32) -> Pin> { debug!("accept {}", listener_rid); - Box::new( - futures::future::poll_fn(move || { - let mut table = RESOURCE_TABLE.lock().unwrap(); - let maybe_repr = table.get_mut(&listener_rid); - match maybe_repr { - Some(Repr::TcpListener(ref mut listener)) => listener.poll_accept(), - _ => panic!("bad rid {}", listener_rid), - } - }).and_then(move |(stream, addr)| { - debug!("accept success {}", addr); - let rid = new_rid(); + futures::future::poll_fn(move |_cx| { + let mut table = RESOURCE_TABLE.lock().unwrap(); + let maybe_repr = table.get_mut(&listener_rid); + match maybe_repr { + Some(Repr::TcpListener(ref mut listener)) => match listener.poll_accept() + { + Ok(Async::Ready(v)) => Poll::Ready(Ok(v)), + Ok(Async::NotReady) => Poll::Pending, + Err(err) => Poll::Ready(Err(err)), + }, + _ => panic!("bad rid {}", listener_rid), + } + }) + .and_then(move |(stream, addr)| { + debug!("accept success {}", addr); + let rid = new_rid(); - let mut guard = RESOURCE_TABLE.lock().unwrap(); - guard.insert(rid, Repr::TcpStream(stream)); + let mut guard = RESOURCE_TABLE.lock().unwrap(); + guard.insert(rid, Repr::TcpStream(stream)); - Ok(rid as i32) - }), - ) + futures::future::ok(rid as i32) + }) + .boxed() } -fn op_listen() -> Box { +fn op_listen() -> Pin> { debug!("listen"); - Box::new(lazy(move || { + lazy(move |_cx| { let addr = "127.0.0.1:4544".parse::().unwrap(); let listener = tokio::net::TcpListener::bind(&addr).unwrap(); let rid = new_rid(); let mut guard = RESOURCE_TABLE.lock().unwrap(); guard.insert(rid, Repr::TcpListener(listener)); - futures::future::ok(rid) - })) + Ok(rid) + }) + .boxed() } -fn op_close(rid: i32) -> Box { +fn op_close(rid: i32) -> Pin> { debug!("close"); - Box::new(lazy(move || { + lazy(move |_cx| { let mut table = RESOURCE_TABLE.lock().unwrap(); let r = table.remove(&rid); let result = if r.is_some() { 0 } else { -1 }; - futures::future::ok(result) - })) + Ok(result) + }) + .boxed() } -fn op_read(rid: i32, zero_copy_buf: Option) -> Box { +fn op_read( + rid: i32, + zero_copy_buf: Option, +) -> Pin> { debug!("read rid={}", rid); let mut zero_copy_buf = zero_copy_buf.unwrap(); - Box::new( - futures::future::poll_fn(move || { - let mut table = RESOURCE_TABLE.lock().unwrap(); - let maybe_repr = table.get_mut(&rid); - match maybe_repr { - Some(Repr::TcpStream(ref mut stream)) => { - stream.poll_read(&mut zero_copy_buf) + futures::future::poll_fn(move |_cx| { + let mut table = RESOURCE_TABLE.lock().unwrap(); + let maybe_repr = table.get_mut(&rid); + match maybe_repr { + Some(Repr::TcpStream(ref mut stream)) => { + match stream.poll_read(&mut zero_copy_buf) { + Ok(Async::Ready(v)) => Poll::Ready(Ok(v)), + Ok(Async::NotReady) => Poll::Pending, + Err(err) => Poll::Ready(Err(err)), } - _ => panic!("bad rid"), } - }).and_then(move |nread| { - debug!("read success {}", nread); - Ok(nread as i32) - }), - ) + _ => panic!("bad rid"), + } + }) + .and_then(move |nread| { + debug!("read success {}", nread); + futures::future::ok(nread as i32) + }) + .boxed() } -fn op_write(rid: i32, zero_copy_buf: Option) -> Box { +fn op_write( + rid: i32, + zero_copy_buf: Option, +) -> Pin> { debug!("write rid={}", rid); let zero_copy_buf = zero_copy_buf.unwrap(); - Box::new( - futures::future::poll_fn(move || { - let mut table = RESOURCE_TABLE.lock().unwrap(); - let maybe_repr = table.get_mut(&rid); - match maybe_repr { - Some(Repr::TcpStream(ref mut stream)) => { - stream.poll_write(&zero_copy_buf) + futures::future::poll_fn(move |_cx| { + let mut table = RESOURCE_TABLE.lock().unwrap(); + let maybe_repr = table.get_mut(&rid); + match maybe_repr { + Some(Repr::TcpStream(ref mut stream)) => { + match stream.poll_write(&zero_copy_buf) { + Ok(Async::Ready(v)) => Poll::Ready(Ok(v)), + Ok(Async::NotReady) => Poll::Pending, + Err(err) => Poll::Ready(Err(err)), } - _ => panic!("bad rid"), } - }).and_then(move |nwritten| { - debug!("write success {}", nwritten); - Ok(nwritten as i32) - }), - ) + _ => panic!("bad rid"), + } + }) + .and_then(move |nwritten| { + debug!("write success {}", nwritten); + futures::future::ok(nwritten as i32) + }) + .boxed() } fn js_check(r: Result<(), ErrBox>) { diff --git a/core/flags.rs b/core/flags.rs index 4deca6e2dca51..e1429ab9a0130 100644 --- a/core/flags.rs +++ b/core/flags.rs @@ -39,5 +39,6 @@ pub fn v8_set_flags(args: Vec) -> Vec { let cstr = CStr::from_ptr(*ptr as *const c_char); let slice = cstr.to_str().unwrap(); slice.to_string() - }).collect() + }) + .collect() } diff --git a/core/isolate.rs b/core/isolate.rs index af9d07f753fd5..ccf83770e54fe 100644 --- a/core/isolate.rs +++ b/core/isolate.rs @@ -17,32 +17,39 @@ use crate::libdeno::Snapshot1; use crate::libdeno::Snapshot2; use crate::shared_queue::SharedQueue; use crate::shared_queue::RECOMMENDED_SIZE; -use futures::stream::{FuturesUnordered, Stream}; -use futures::task; -use futures::Async::*; -use futures::Future; -use futures::Poll; +use futures::future::FutureExt; +use futures::stream::{FuturesUnordered, StreamExt}; use libc::c_char; use libc::c_void; use std::ffi::CStr; use std::ffi::CString; +use std::future::Future; +use std::pin::Pin; use std::ptr::null; use std::sync::{Arc, Mutex, Once}; +use std::task::Context; +use std::task::Poll; pub type Buf = Box<[u8]>; -pub type OpAsyncFuture = Box + Send>; +pub type OpAsyncFuture = Pin + Send>>; -pub enum Op { +pub enum Op { Sync(Buf), - Async(OpAsyncFuture), + Async(OpAsyncFuture), } -pub type CoreError = (); +type ResultOutput = Result; -type CoreOpAsyncFuture = OpAsyncFuture; +pub type ResultOp = Op>; -pub type CoreOp = Op; +pub type ResultOpResult = Result, E>; + +pub type CoreOuput = Buf; + +type CoreOpAsyncFuture = OpAsyncFuture; + +pub type CoreOp = Op; /// Stores a script used to initalize a Isolate pub struct Script<'a> { @@ -76,11 +83,10 @@ pub enum StartupData<'a> { None, } -pub type OpResult = Result, E>; - type CoreDispatchFn = dyn Fn(&[u8], Option) -> CoreOp; -pub type DynImportFuture = Box + Send>; +pub type DynImportFuture = + Pin> + Send>>; type DynImportFn = dyn Fn(&str, &str) -> DynImportFuture; type JSErrorCreateFn = dyn Fn(V8Exception) -> ErrBox; @@ -92,15 +98,17 @@ struct DynImport { inner: DynImportFuture, } +impl Unpin for DynImport {} + impl Future for DynImport { - type Item = (deno_dyn_import_id, deno_mod); - type Error = (); - fn poll(&mut self) -> Poll { - match self.inner.poll() { - Ok(Ready(mod_id)) => Ok(Ready((self.id, mod_id))), - Ok(NotReady) => Ok(NotReady), - // Note that mod_id 0 indicates error. - Err(()) => Ok(Ready((self.id, 0))), + type Output = (deno_dyn_import_id, deno_mod); + + fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { + let self_mut = self.get_mut(); + match self_mut.inner.poll_unpin(cx) { + Poll::Ready(Ok(mod_id)) => Poll::Ready((self_mut.id, mod_id)), + Poll::Ready(Err(())) => Poll::Ready((self_mut.id, 0)), + Poll::Pending => Poll::Pending, } } } @@ -129,6 +137,8 @@ pub struct Isolate { unsafe impl Send for Isolate {} +impl Unpin for Isolate {} + impl Drop for Isolate { fn drop(&mut self) { // remove shared_libdeno_isolate reference @@ -256,7 +266,8 @@ impl Isolate { if let Some(ref f) = isolate.dyn_import { let inner = f(specifier, referrer); let fut = DynImport { inner, id }; - task::current().notify(); + // TODO(afinch7) figure how to handle this with new futures api. + // task::current().notify(); isolate.pending_dyn_imports.push(fut); } else { panic!("dyn_import callback not set") @@ -546,35 +557,34 @@ impl Drop for LockerScope { } impl Future for Isolate { - type Item = (); - type Error = ErrBox; + type Output = Result<(), ErrBox>; - fn poll(&mut self) -> Poll<(), ErrBox> { - self.shared_init(); + fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { + let isolate = self.get_mut(); + + isolate.shared_init(); let mut overflow_response: Option = None; loop { // If there are any pending dyn_import futures, do those first. - match self.pending_dyn_imports.poll() { - Err(()) => unreachable!(), - Ok(NotReady) => unreachable!(), - Ok(Ready(None)) => (), - Ok(Ready(Some((dyn_import_id, mod_id)))) => { - self.dyn_import_done(dyn_import_id, mod_id)?; + match isolate.pending_dyn_imports.poll_next_unpin(cx) { + Poll::Pending => (), + Poll::Ready(None) => (), + Poll::Ready(Some((dyn_import_id, mod_id))) => { + isolate.dyn_import_done(dyn_import_id, mod_id)?; continue; } } // Now handle actual ops. - self.have_unpolled_ops = false; + isolate.have_unpolled_ops = false; #[allow(clippy::match_wild_err_arm)] - match self.pending_ops.poll() { - Err(_) => panic!("unexpected op error"), - Ok(Ready(None)) => break, - Ok(NotReady) => break, - Ok(Ready(Some(buf))) => { - let successful_push = self.shared.push(&buf); + match isolate.pending_ops.poll_next_unpin(cx) { + Poll::Pending => break, + Poll::Ready(None) => break, + Poll::Ready(Some(buf)) => { + let successful_push = isolate.shared.push(&buf); if !successful_push { // If we couldn't push the response to the shared queue, because // there wasn't enough size, we will return the buffer via the @@ -586,34 +596,36 @@ impl Future for Isolate { } } - if self.shared.size() > 0 { + if isolate.shared.size() > 0 { // Lock the current thread for V8. - let locker = LockerScope::new(self.libdeno_isolate); - self.respond(None)?; + let locker = LockerScope::new(isolate.libdeno_isolate); + isolate.respond(None)?; // The other side should have shifted off all the messages. - assert_eq!(self.shared.size(), 0); + assert_eq!(isolate.shared.size(), 0); drop(locker); } if overflow_response.is_some() { // Lock the current thread for V8. - let locker = LockerScope::new(self.libdeno_isolate); + let locker = LockerScope::new(isolate.libdeno_isolate); let buf = overflow_response.take().unwrap(); - self.respond(Some(&buf))?; + isolate.respond(Some(&buf))?; drop(locker); } - self.check_promise_errors(); - self.check_last_exception()?; + isolate.check_promise_errors(); + if let Err(err) = isolate.check_last_exception() { + return Poll::Ready(Err(err)); + } // We're idle if pending_ops is empty. - if self.pending_ops.is_empty() { - Ok(futures::Async::Ready(())) + if isolate.pending_ops.is_empty() { + Poll::Ready(Ok(())) } else { - if self.have_unpolled_ops { - task::current().notify(); + if isolate.have_unpolled_ops { + cx.waker().wake_by_ref(); } - Ok(futures::Async::NotReady) + Poll::Pending } } } @@ -648,32 +660,31 @@ pub fn js_check(r: Result<(), ErrBox>) { #[cfg(test)] pub mod tests { use super::*; - use futures::executor::spawn; + use futures::executor::ThreadPool; use futures::future::lazy; - use futures::future::ok; - use futures::Async; - use std::ops::FnOnce; + use futures::task::Context; use std::sync::atomic::{AtomicUsize, Ordering}; fn run_in_task(f: F) -> R where - F: FnOnce() -> R, + F: FnOnce(&mut Context) -> R, { - spawn(lazy(move || ok::(f()))).wait_future().unwrap() + let mut pool = ThreadPool::new().unwrap(); + pool.run(lazy(move |cx| f(cx))) } fn poll_until_ready( future: &mut F, + cx: &mut Context, max_poll_count: usize, - ) -> Result + ) -> F::Output where - F: Future, + F: Future + Unpin, { for _ in 0..max_poll_count { - match future.poll() { - Ok(NotReady) => continue, - Ok(Ready(val)) => return Ok(val), - Err(err) => return Err(err), + match future.poll_unpin(cx) { + Poll::Pending => continue, + Poll::Ready(val) => return val, } } panic!( @@ -702,7 +713,7 @@ pub mod tests { assert_eq!(control.len(), 1); assert_eq!(control[0], 42); let buf = vec![43u8].into_boxed_slice(); - Op::Async(Box::new(futures::future::ok(buf))) + Op::Async(futures::future::ready(buf).boxed()) } Mode::OverflowReqSync => { assert_eq!(control.len(), 100 * 1024 * 1024); @@ -721,7 +732,7 @@ pub mod tests { Mode::OverflowReqAsync => { assert_eq!(control.len(), 100 * 1024 * 1024); let buf = vec![43u8].into_boxed_slice(); - Op::Async(Box::new(futures::future::ok(buf))) + Op::Async(futures::future::ready(buf).boxed()) } Mode::OverflowResAsync => { assert_eq!(control.len(), 1); @@ -730,7 +741,7 @@ pub mod tests { vec.resize(100 * 1024 * 1024, 0); vec[0] = 4; let buf = vec.into_boxed_slice(); - Op::Async(Box::new(futures::future::ok(buf))) + Op::Async(futures::future::ready(buf).boxed()) } } }); @@ -778,7 +789,8 @@ pub mod tests { let control = new Uint8Array([42]); Deno.core.send(control); "#, - ).unwrap(); + ) + .unwrap(); assert_eq!(dispatch_count.load(Ordering::Relaxed), 0); let imports = isolate.mod_get_imports(mod_a); @@ -814,7 +826,7 @@ pub mod tests { #[test] fn test_poll_async_immediate_ops() { - run_in_task(|| { + run_in_task(|cx| { let (mut isolate, dispatch_count) = setup(Mode::AsyncImmediate); js_check(isolate.execute( @@ -837,7 +849,10 @@ pub mod tests { "#, )); assert_eq!(dispatch_count.load(Ordering::Relaxed), 1); - assert_eq!(Async::Ready(()), isolate.poll().unwrap()); + assert!(match isolate.poll_unpin(cx) { + Poll::Ready(Ok(_)) => true, + _ => false, + }); assert_eq!(dispatch_count.load(Ordering::Relaxed), 1); js_check(isolate.execute( "check2.js", @@ -848,17 +863,23 @@ pub mod tests { "#, )); assert_eq!(dispatch_count.load(Ordering::Relaxed), 2); - assert_eq!(Async::Ready(()), isolate.poll().unwrap()); + assert!(match isolate.poll_unpin(cx) { + Poll::Ready(Ok(_)) => true, + _ => false, + }); js_check(isolate.execute("check3.js", "assert(nrecv == 2)")); assert_eq!(dispatch_count.load(Ordering::Relaxed), 2); // We are idle, so the next poll should be the last. - assert_eq!(Async::Ready(()), isolate.poll().unwrap()); + assert!(match isolate.poll_unpin(cx) { + Poll::Ready(Ok(_)) => true, + _ => false, + }); }); } #[test] fn test_shared() { - run_in_task(|| { + run_in_task(|cx| { let (mut isolate, dispatch_count) = setup(Mode::AsyncImmediate); js_check(isolate.execute( @@ -888,7 +909,10 @@ pub mod tests { "#, )); assert_eq!(dispatch_count.load(Ordering::Relaxed), 2); - assert_eq!(Async::Ready(()), isolate.poll().unwrap()); + assert!(match isolate.poll_unpin(cx) { + Poll::Ready(Ok(_)) => true, + _ => false, + }); js_check(isolate.execute("send1.js", "assert(nrecv === 2);")); }); } @@ -896,7 +920,7 @@ pub mod tests { #[test] fn dyn_import_err() { // Test an erroneous dynamic import where the specified module isn't found. - run_in_task(|| { + run_in_task(|cx| { let count = Arc::new(AtomicUsize::new(0)); let count_ = count.clone(); let mut isolate = Isolate::new(StartupData::None, false); @@ -904,7 +928,7 @@ pub mod tests { count_.fetch_add(1, Ordering::Relaxed); assert_eq!(specifier, "foo.js"); assert_eq!(referrer, "dyn_import2.js"); - Box::new(futures::future::err(())) + futures::future::err(()).boxed() }); js_check(isolate.execute( "dyn_import2.js", @@ -917,14 +941,15 @@ pub mod tests { assert_eq!(count.load(Ordering::Relaxed), 1); // We should get an error here. - let result = isolate.poll(); - assert!(result.is_err()); + if let Poll::Ready(result) = isolate.poll_unpin(cx) { + assert!(result.is_ok()); + }; }) } #[test] fn dyn_import_ok() { - run_in_task(|| { + run_in_task(|cx| { let count = Arc::new(AtomicUsize::new(0)); let count_ = count.clone(); @@ -939,7 +964,7 @@ pub mod tests { // assert_eq!(specifier, "foo.js"); assert_eq!(referrer, "dyn_import3.js"); let mod_id = mod_b2.lock().unwrap(); - Box::new(futures::future::ok(*mod_id)) + futures::future::ok(*mod_id).boxed() }); // Instantiate mod_b @@ -972,9 +997,15 @@ pub mod tests { )); assert_eq!(count.load(Ordering::Relaxed), 1); - assert_eq!(Ready(()), isolate.poll().unwrap()); + assert!(match isolate.poll_unpin(cx) { + Poll::Ready(Ok(_)) => true, + _ => false, + }); assert_eq!(count.load(Ordering::Relaxed), 2); - assert_eq!(Ready(()), isolate.poll().unwrap()); + assert!(match isolate.poll_unpin(cx) { + Poll::Ready(Ok(_)) => true, + _ => false, + }); assert_eq!(count.load(Ordering::Relaxed), 2); }) } @@ -1093,7 +1124,7 @@ pub mod tests { #[test] fn overflow_req_async() { - run_in_task(|| { + run_in_task(|cx| { let (mut isolate, dispatch_count) = setup(Mode::OverflowReqAsync); js_check(isolate.execute( "overflow_req_async.js", @@ -1113,14 +1144,17 @@ pub mod tests { "#, )); assert_eq!(dispatch_count.load(Ordering::Relaxed), 1); - assert_eq!(Async::Ready(()), isolate.poll().unwrap()); + assert!(match isolate.poll_unpin(cx) { + Poll::Ready(Ok(_)) => true, + _ => false, + }); js_check(isolate.execute("check.js", "assert(asyncRecv == 1);")); }); } #[test] fn overflow_res_async() { - run_in_task(|| { + run_in_task(|cx| { // TODO(ry) This test is quite slow due to memcpy-ing 100MB into JS. We // should optimize this. let (mut isolate, dispatch_count) = setup(Mode::OverflowResAsync); @@ -1141,7 +1175,7 @@ pub mod tests { "#, )); assert_eq!(dispatch_count.load(Ordering::Relaxed), 1); - poll_until_ready(&mut isolate, 3).unwrap(); + assert!(poll_until_ready(&mut isolate, cx, 3).is_ok()); js_check(isolate.execute("check.js", "assert(asyncRecv == 1);")); }); } @@ -1150,7 +1184,7 @@ pub mod tests { fn overflow_res_multiple_dispatch_async() { // TODO(ry) This test is quite slow due to memcpy-ing 100MB into JS. We // should optimize this. - run_in_task(|| { + run_in_task(|cx| { let (mut isolate, dispatch_count) = setup(Mode::OverflowResAsync); js_check(isolate.execute( "overflow_res_multiple_dispatch_async.js", @@ -1172,14 +1206,14 @@ pub mod tests { "#, )); assert_eq!(dispatch_count.load(Ordering::Relaxed), 2); - poll_until_ready(&mut isolate, 3).unwrap(); + assert!(poll_until_ready(&mut isolate, cx, 3).is_ok()); js_check(isolate.execute("check.js", "assert(asyncRecv == 2);")); }); } #[test] fn test_js() { - run_in_task(|| { + run_in_task(|cx| { let (mut isolate, _dispatch_count) = setup(Mode::AsyncImmediate); js_check( isolate.execute( @@ -1187,7 +1221,11 @@ pub mod tests { include_str!("shared_queue_test.js"), ), ); - assert_eq!(Async::Ready(()), isolate.poll().unwrap()); + let poll = isolate.poll_unpin(cx); + assert!(match poll { + Poll::Ready(Ok(_)) => true, + _ => false, + }) }); } diff --git a/core/js_errors.rs b/core/js_errors.rs index 08cb00a7289b0..3656242e09d74 100644 --- a/core/js_errors.rs +++ b/core/js_errors.rs @@ -310,7 +310,8 @@ mod tests { "isConstructor":false, "isWasm":false }"#, - ).unwrap(); + ) + .unwrap(); let r = StackFrame::from_json_value(&v); assert_eq!( r, @@ -334,7 +335,8 @@ mod tests { "line": 2, "column": 11 }"#, - ).unwrap(); + ) + .unwrap(); let r = StackFrame::from_json_value(&v); assert!(r.is_some()); let f = r.unwrap(); diff --git a/core/modules.rs b/core/modules.rs index 4b0d128f2a155..ed4e97f98df11 100644 --- a/core/modules.rs +++ b/core/modules.rs @@ -10,15 +10,17 @@ use crate::any_error::ErrBox; use crate::isolate::Isolate; use crate::libdeno::deno_mod; use crate::module_specifier::ModuleSpecifier; -use futures::Async; -use futures::Future; -use futures::Poll; +use futures::future::FutureExt; use std::collections::HashMap; use std::collections::HashSet; use std::fmt; +use std::future::Future; use std::marker::PhantomData; +use std::pin::Pin; use std::sync::Arc; use std::sync::Mutex; +use std::task::Context; +use std::task::Poll; /// Represent result of fetching the source code of a module. /// Contains both module name and code. @@ -34,7 +36,7 @@ pub struct SourceCodeInfo { } pub type SourceCodeInfoFuture = - dyn Future + Send; + dyn Future> + Send; pub trait Loader: Send + Sync { /// Returns an absolute URL. @@ -52,13 +54,13 @@ pub trait Loader: Send + Sync { fn load( &self, module_specifier: &ModuleSpecifier, - ) -> Box; + ) -> Pin>; } struct PendingLoad { url: String, is_root: bool, - source_code_info_future: Box, + source_code_info_future: Pin>, } /// This future is used to implement parallel async module loading without @@ -77,6 +79,8 @@ pub struct RecursiveLoad { root_id: Option, } +impl Unpin for RecursiveLoad {} + impl RecursiveLoad { /// Starts a new parallel load of the given URL. pub fn new( @@ -140,37 +144,37 @@ impl RecursiveLoad { } impl Future for RecursiveLoad { - type Item = deno_mod; - type Error = ErrBox; + type Output = Result; - fn poll(&mut self) -> Poll { - if self.root.is_none() && self.root_specifier.is_some() { - let s = self.root_specifier.take().unwrap(); - match self.add(&s, ".", None) { + fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { + let mut load = self.get_mut(); + if load.root.is_none() && load.root_specifier.is_some() { + let s = load.root_specifier.take().unwrap(); + match load.add(&s, ".", None) { Err(err) => { - return Err(err); + return Poll::Ready(Err(err)); } Ok(root) => { - self.root = Some(root); + load.root = Some(root); } } } - assert!(self.root_specifier.is_none()); - assert!(self.root.is_some()); + assert!(load.root_specifier.is_none()); + assert!(load.root.is_some()); let mut i = 0; - while i < self.pending.len() { - let pending = &mut self.pending[i]; - match pending.source_code_info_future.poll() { - Err(err) => { - return Err(err); + while i < load.pending.len() { + let pending = &mut load.pending[i]; + match pending.source_code_info_future.poll_unpin(cx) { + Poll::Ready(Err(err)) => { + return Poll::Ready(Err(err)); } - Ok(Async::NotReady) => { + Poll::Pending => { i += 1; } - Ok(Async::Ready(source_code_info)) => { + Poll::Ready(Ok(source_code_info)) => { // We have completed loaded one of the modules. - let completed = self.pending.remove(i); + let completed = load.pending.remove(i); // #A There are 3 cases to handle at this moment: // 1. Source code resolved result have the same module name as requested @@ -182,7 +186,7 @@ impl Future for RecursiveLoad { // 2b. The module with resolved module name has not yet been registerd // -> register & alias let is_module_registered = { - let modules = self.modules.lock().unwrap(); + let modules = load.modules.lock().unwrap(); modules.is_registered(&source_code_info.module_name) }; @@ -191,23 +195,26 @@ impl Future for RecursiveLoad { if !is_module_registered { let module_name = &source_code_info.module_name; - let mod_id = { - let isolate = self.isolate.lock().unwrap(); + let result = { + let isolate = load.isolate.lock().unwrap(); isolate.mod_new( completed.is_root, module_name, &source_code_info.code, ) - }?; - + }; + if let Err(err) = result { + return Poll::Ready(Err(err)); + } + let mod_id = result.unwrap(); if completed.is_root { - assert!(self.root_id.is_none()); - self.root_id = Some(mod_id); + assert!(load.root_id.is_none()); + load.root_id = Some(mod_id); } // Register new module. { - let mut modules = self.modules.lock().unwrap(); + let mut modules = load.modules.lock().unwrap(); modules.register(mod_id, module_name); // If necessary, register the alias. if need_alias { @@ -218,46 +225,51 @@ impl Future for RecursiveLoad { // Now we must iterate over all imports of the module and load them. let imports = { - let isolate = self.isolate.lock().unwrap(); + let isolate = load.isolate.lock().unwrap(); isolate.mod_get_imports(mod_id) }; let referrer = module_name; for specifier in imports { - self.add(&specifier, referrer, Some(mod_id))?; + load.add(&specifier, referrer, Some(mod_id))?; } } else if need_alias { - let mut modules = self.modules.lock().unwrap(); + let mut modules = load.modules.lock().unwrap(); modules.alias(&completed.url, &source_code_info.module_name); } } } } - if !self.pending.is_empty() { - return Ok(Async::NotReady); + if !load.pending.is_empty() { + return Poll::Pending; } - let root_id = self.root_id.unwrap(); + let root_id = load.root_id.unwrap(); + let result = { + let mut resolve_cb = + |specifier: &str, referrer_id: deno_mod| -> deno_mod { + let modules = load.modules.lock().unwrap(); + let referrer = modules.get_name(referrer_id).unwrap(); + // this callback is only called for non-root modules + match load.loader.resolve(specifier, &referrer, false) { + Ok(specifier) => match modules.get_id(&specifier.to_string()) { + Some(id) => id, + None => 0, + }, + // We should have already resolved and loaded this module, so + // resolve() will not fail this time. + Err(_err) => unreachable!(), + } + }; - let mut resolve_cb = |specifier: &str, referrer_id: deno_mod| -> deno_mod { - let modules = self.modules.lock().unwrap(); - let referrer = modules.get_name(referrer_id).unwrap(); - // this callback is only called for non-root modules - match self.loader.resolve(specifier, &referrer, false) { - Ok(specifier) => match modules.get_id(&specifier.to_string()) { - Some(id) => id, - None => 0, - }, - // We should have already resolved and loaded this module, so - // resolve() will not fail this time. - Err(_err) => unreachable!(), - } + let mut isolate = load.isolate.lock().unwrap(); + isolate.mod_instantiate(root_id, &mut resolve_cb) }; - let mut isolate = self.isolate.lock().unwrap(); - isolate - .mod_instantiate(root_id, &mut resolve_cb) - .map(|_| Async::Ready(root_id)) + match result { + Err(err) => Poll::Ready(Err(err)), + Ok(()) => Poll::Ready(Ok(root_id)), + } } } @@ -384,7 +396,8 @@ impl Modules { if !i.has_child(&child_name) { i.children.push(child_name.to_string()); } - }).is_some() + }) + .is_some() } pub fn register(&mut self, id: deno_mod, name: &str) { @@ -518,9 +531,19 @@ mod tests { use super::*; use crate::isolate::js_check; use crate::isolate::tests::*; + use futures::executor::ThreadPool; + use futures::future::lazy; use std::error::Error; use std::fmt; + fn run_in_task(f: F) -> R + where + F: FnOnce(&mut Context) -> R, + { + let mut pool = ThreadPool::new().unwrap(); + pool.run(lazy(move |cx| f(cx))) + } + struct MockLoader { pub loads: Arc>>, pub isolate: Arc>, @@ -588,22 +611,22 @@ mod tests { } impl Future for DelayedSourceCodeFuture { - type Item = SourceCodeInfo; - type Error = ErrBox; + type Output = Result; - fn poll(&mut self) -> Poll { - self.counter += 1; - if self.url == "file:///never_ready.js" - || (self.url == "file:///slow.js" && self.counter < 2) + fn poll(self: Pin<&mut Self>, _cx: &mut Context) -> Poll { + let inner = Pin::get_mut(self); + inner.counter += 1; + if inner.url == "file:///never_ready.js" + || (inner.url == "file:///slow.js" && inner.counter < 2) { - return Ok(Async::NotReady); + return Poll::Pending; } - match mock_source_code(&self.url) { - Some(src) => Ok(Async::Ready(SourceCodeInfo { + match mock_source_code(&inner.url) { + Some(src) => Poll::Ready(Ok(SourceCodeInfo { code: src.0.to_owned(), module_name: src.1.to_owned(), })), - None => Err(MockError::LoadErr.into()), + None => Poll::Ready(Err(MockError::LoadErr.into())), } } } @@ -639,11 +662,11 @@ mod tests { fn load( &self, module_specifier: &ModuleSpecifier, - ) -> Box { + ) -> Pin> { let mut loads = self.loads.lock().unwrap(); loads.push(module_specifier.to_string()); let url = module_specifier.to_string(); - Box::new(DelayedSourceCodeFuture { url, counter: 0 }) + DelayedSourceCodeFuture { url, counter: 0 }.boxed() } } @@ -680,58 +703,60 @@ mod tests { #[test] fn test_recursive_load() { - let loader = MockLoader::new(); - let modules = loader.modules.clone(); - let modules_ = modules.clone(); - let isolate = loader.isolate.clone(); - let isolate_ = isolate.clone(); - let loads = loader.loads.clone(); - let mut recursive_load = - RecursiveLoad::new("/a.js", loader, isolate, modules); - - let result = recursive_load.poll(); - assert!(result.is_ok()); - if let Async::Ready(a_id) = result.ok().unwrap() { - let mut isolate = isolate_.lock().unwrap(); - js_check(isolate.mod_evaluate(a_id)); - - let l = loads.lock().unwrap(); - assert_eq!( - l.to_vec(), - vec![ - "file:///a.js", - "file:///b.js", - "file:///c.js", - "file:///d.js" - ] - ); - - let modules = modules_.lock().unwrap(); - - assert_eq!(modules.get_id("file:///a.js"), Some(a_id)); - let b_id = modules.get_id("file:///b.js").unwrap(); - let c_id = modules.get_id("file:///c.js").unwrap(); - let d_id = modules.get_id("file:///d.js").unwrap(); - - assert_eq!( - modules.get_children(a_id), - Some(&vec![ - "file:///b.js".to_string(), - "file:///c.js".to_string() - ]) - ); - assert_eq!( - modules.get_children(b_id), - Some(&vec!["file:///c.js".to_string()]) - ); - assert_eq!( - modules.get_children(c_id), - Some(&vec!["file:///d.js".to_string()]) - ); - assert_eq!(modules.get_children(d_id), Some(&vec![])); - } else { - unreachable!(); - } + run_in_task(|cx| { + let loader = MockLoader::new(); + let modules = loader.modules.clone(); + let modules_ = modules.clone(); + let isolate = loader.isolate.clone(); + let isolate_ = isolate.clone(); + let loads = loader.loads.clone(); + let mut recursive_load = + RecursiveLoad::new("/a.js", loader, isolate, modules); + + if let Poll::Ready(result) = recursive_load.poll_unpin(cx) { + assert!(result.is_ok()); + let a_id = result.unwrap(); + let mut isolate = isolate_.lock().unwrap(); + js_check(isolate.mod_evaluate(a_id)); + + let l = loads.lock().unwrap(); + assert_eq!( + l.to_vec(), + vec![ + "file:///a.js", + "file:///b.js", + "file:///c.js", + "file:///d.js" + ] + ); + + let modules = modules_.lock().unwrap(); + + assert_eq!(modules.get_id("file:///a.js"), Some(a_id)); + let b_id = modules.get_id("file:///b.js").unwrap(); + let c_id = modules.get_id("file:///c.js").unwrap(); + let d_id = modules.get_id("file:///d.js").unwrap(); + + assert_eq!( + modules.get_children(a_id), + Some(&vec![ + "file:///b.js".to_string(), + "file:///c.js".to_string() + ]) + ); + assert_eq!( + modules.get_children(b_id), + Some(&vec!["file:///c.js".to_string()]) + ); + assert_eq!( + modules.get_children(c_id), + Some(&vec!["file:///d.js".to_string()]) + ); + assert_eq!(modules.get_children(d_id), Some(&vec![])); + } else { + unreachable!(); + } + }) } const CIRCULAR1_SRC: &str = r#" @@ -752,58 +777,60 @@ mod tests { #[test] fn test_circular_load() { - let loader = MockLoader::new(); - let isolate = loader.isolate.clone(); - let isolate_ = isolate.clone(); - let modules = loader.modules.clone(); - let modules_ = modules.clone(); - let loads = loader.loads.clone(); - let mut recursive_load = - RecursiveLoad::new("/circular1.js", loader, isolate, modules); - - let result = recursive_load.poll(); - assert!(result.is_ok()); - if let Async::Ready(circular1_id) = result.ok().unwrap() { - let mut isolate = isolate_.lock().unwrap(); - js_check(isolate.mod_evaluate(circular1_id)); - - let l = loads.lock().unwrap(); - assert_eq!( - l.to_vec(), - vec![ - "file:///circular1.js", - "file:///circular2.js", - "file:///circular3.js" - ] - ); - - let modules = modules_.lock().unwrap(); - - assert_eq!(modules.get_id("file:///circular1.js"), Some(circular1_id)); - let circular2_id = modules.get_id("file:///circular2.js").unwrap(); - - assert_eq!( - modules.get_children(circular1_id), - Some(&vec!["file:///circular2.js".to_string()]) - ); - - assert_eq!( - modules.get_children(circular2_id), - Some(&vec!["file:///circular3.js".to_string()]) - ); - - assert!(modules.get_id("file:///circular3.js").is_some()); - let circular3_id = modules.get_id("file:///circular3.js").unwrap(); - assert_eq!( - modules.get_children(circular3_id), - Some(&vec![ - "file:///circular1.js".to_string(), - "file:///circular2.js".to_string() - ]) - ); - } else { - unreachable!(); - } + run_in_task(|cx| { + let loader = MockLoader::new(); + let isolate = loader.isolate.clone(); + let isolate_ = isolate.clone(); + let modules = loader.modules.clone(); + let modules_ = modules.clone(); + let loads = loader.loads.clone(); + let mut recursive_load = + RecursiveLoad::new("/circular1.js", loader, isolate, modules); + + if let Poll::Ready(result) = recursive_load.poll_unpin(cx) { + assert!(result.is_ok()); + let circular1_id = result.unwrap(); + let mut isolate = isolate_.lock().unwrap(); + js_check(isolate.mod_evaluate(circular1_id)); + + let l = loads.lock().unwrap(); + assert_eq!( + l.to_vec(), + vec![ + "file:///circular1.js", + "file:///circular2.js", + "file:///circular3.js" + ] + ); + + let modules = modules_.lock().unwrap(); + + assert_eq!(modules.get_id("file:///circular1.js"), Some(circular1_id)); + let circular2_id = modules.get_id("file:///circular2.js").unwrap(); + + assert_eq!( + modules.get_children(circular1_id), + Some(&vec!["file:///circular2.js".to_string()]) + ); + + assert_eq!( + modules.get_children(circular2_id), + Some(&vec!["file:///circular3.js".to_string()]) + ); + + assert!(modules.get_id("file:///circular3.js").is_some()); + let circular3_id = modules.get_id("file:///circular3.js").unwrap(); + assert_eq!( + modules.get_children(circular3_id), + Some(&vec![ + "file:///circular1.js".to_string(), + "file:///circular2.js".to_string() + ]) + ); + } else { + unreachable!(); + } + }); } const REDIRECT1_SRC: &str = r#" @@ -822,49 +849,51 @@ mod tests { #[test] fn test_redirect_load() { - let loader = MockLoader::new(); - let isolate = loader.isolate.clone(); - let isolate_ = isolate.clone(); - let modules = loader.modules.clone(); - let modules_ = modules.clone(); - let loads = loader.loads.clone(); - let mut recursive_load = - RecursiveLoad::new("/redirect1.js", loader, isolate, modules); - - let result = recursive_load.poll(); - assert!(result.is_ok()); - if let Async::Ready(redirect1_id) = result.ok().unwrap() { - let mut isolate = isolate_.lock().unwrap(); - js_check(isolate.mod_evaluate(redirect1_id)); - let l = loads.lock().unwrap(); - assert_eq!( - l.to_vec(), - vec![ - "file:///redirect1.js", - "file:///redirect2.js", - "file:///dir/redirect3.js" - ] - ); - - let modules = modules_.lock().unwrap(); - - assert_eq!(modules.get_id("file:///redirect1.js"), Some(redirect1_id)); - - let redirect2_id = modules.get_id("file:///dir/redirect2.js").unwrap(); - assert!(modules.is_alias("file:///redirect2.js")); - assert!(!modules.is_alias("file:///dir/redirect2.js")); - assert_eq!(modules.get_id("file:///redirect2.js"), Some(redirect2_id)); - - let redirect3_id = modules.get_id("file:///redirect3.js").unwrap(); - assert!(modules.is_alias("file:///dir/redirect3.js")); - assert!(!modules.is_alias("file:///redirect3.js")); - assert_eq!( - modules.get_id("file:///dir/redirect3.js"), - Some(redirect3_id) - ); - } else { - unreachable!(); - } + run_in_task(|cx| { + let loader = MockLoader::new(); + let isolate = loader.isolate.clone(); + let isolate_ = isolate.clone(); + let modules = loader.modules.clone(); + let modules_ = modules.clone(); + let loads = loader.loads.clone(); + let mut recursive_load = + RecursiveLoad::new("/redirect1.js", loader, isolate, modules); + + if let Poll::Ready(result) = recursive_load.poll_unpin(cx) { + assert!(result.is_ok()); + let redirect1_id = result.unwrap(); + let mut isolate = isolate_.lock().unwrap(); + js_check(isolate.mod_evaluate(redirect1_id)); + let l = loads.lock().unwrap(); + assert_eq!( + l.to_vec(), + vec![ + "file:///redirect1.js", + "file:///redirect2.js", + "file:///dir/redirect3.js" + ] + ); + + let modules = modules_.lock().unwrap(); + + assert_eq!(modules.get_id("file:///redirect1.js"), Some(redirect1_id)); + + let redirect2_id = modules.get_id("file:///dir/redirect2.js").unwrap(); + assert!(modules.is_alias("file:///redirect2.js")); + assert!(!modules.is_alias("file:///dir/redirect2.js")); + assert_eq!(modules.get_id("file:///redirect2.js"), Some(redirect2_id)); + + let redirect3_id = modules.get_id("file:///redirect3.js").unwrap(); + assert!(modules.is_alias("file:///dir/redirect3.js")); + assert!(!modules.is_alias("file:///redirect3.js")); + assert_eq!( + modules.get_id("file:///dir/redirect3.js"), + Some(redirect3_id) + ); + } else { + unreachable!(); + } + }); } // main.js @@ -885,47 +914,45 @@ mod tests { #[test] fn slow_never_ready_modules() { - let loader = MockLoader::new(); - let isolate = loader.isolate.clone(); - let modules = loader.modules.clone(); - let loads = loader.loads.clone(); - let mut recursive_load = - RecursiveLoad::new("/main.js", loader, isolate, modules); + run_in_task(|cx| { + let loader = MockLoader::new(); + let isolate = loader.isolate.clone(); + let modules = loader.modules.clone(); + let loads = loader.loads.clone(); + let mut recursive_load = + RecursiveLoad::new("/main.js", loader, isolate, modules); - let result = recursive_load.poll(); - assert!(result.is_ok()); - assert!(result.ok().unwrap().is_not_ready()); + assert!(recursive_load.poll_unpin(cx).is_pending()); - { - let l = loads.lock().unwrap(); - assert_eq!( - l.to_vec(), - vec![ - "file:///main.js", - "file:///never_ready.js", - "file:///slow.js" - ] - ); - } + { + let l = loads.lock().unwrap(); + assert_eq!( + l.to_vec(), + vec![ + "file:///main.js", + "file:///never_ready.js", + "file:///slow.js" + ] + ); + } - for _ in 0..10 { - let result = recursive_load.poll(); - assert!(result.is_ok()); - assert!(result.ok().unwrap().is_not_ready()); - let l = loads.lock().unwrap();; - assert_eq!( - l.to_vec(), - vec![ - "file:///main.js", - "file:///never_ready.js", - "file:///slow.js", - "file:///a.js", - "file:///b.js", - "file:///c.js", - "file:///d.js" - ] - ); - } + for _ in 0..10 { + assert!(recursive_load.poll_unpin(cx).is_pending()); + let l = loads.lock().unwrap();; + assert_eq!( + l.to_vec(), + vec![ + "file:///main.js", + "file:///never_ready.js", + "file:///slow.js", + "file:///a.js", + "file:///b.js", + "file:///c.js", + "file:///d.js" + ] + ); + } + }); } // bad_import.js @@ -935,18 +962,23 @@ mod tests { #[test] fn loader_disappears_after_error() { - let loader = MockLoader::new(); - let isolate = loader.isolate.clone(); - let modules = loader.modules.clone(); - let mut recursive_load = - RecursiveLoad::new("/bad_import.js", loader, isolate, modules); - let result = recursive_load.poll(); - assert!(result.is_err()); - let err = result.err().unwrap(); - assert_eq!( - err.downcast_ref::().unwrap(), - &MockError::ResolveErr - ); + run_in_task(|cx| { + let loader = MockLoader::new(); + let isolate = loader.isolate.clone(); + let modules = loader.modules.clone(); + let mut recursive_load = + RecursiveLoad::new("/bad_import.js", loader, isolate, modules); + if let Poll::Ready(result) = recursive_load.poll_unpin(cx) { + assert!(result.is_err()); + let err = result.err().unwrap(); + assert_eq!( + err.downcast_ref::().unwrap(), + &MockError::ResolveErr + ); + } else { + unreachable!(); + } + }); } #[test] diff --git a/third_party b/third_party index e319136a17447..e390b0a69bcad 160000 --- a/third_party +++ b/third_party @@ -1 +1 @@ -Subproject commit e319136a1744710ffd3c2ea372a7dfc1d462f120 +Subproject commit e390b0a69bcad8dbb9fd77ad0501ecaf74681b9e