Bug 1716518 - Upgrade futures to v.0.1.31 and v0.3.15. r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D117790
This commit is contained in:
Mike Hommey 2021-06-15 21:24:42 +00:00
parent 4e0e951844
commit fe2c0ca30d
401 changed files with 6743 additions and 4627 deletions

70
Cargo.lock generated
View File

@ -153,7 +153,7 @@ dependencies = [
"cc",
"cubeb",
"error-chain",
"futures 0.1.29",
"futures 0.1.31",
"iovec",
"libc",
"log",
@ -178,7 +178,7 @@ dependencies = [
"audio_thread_priority",
"audioipc",
"cubeb-backend",
"futures 0.1.29",
"futures 0.1.31",
"futures-cpupool",
"log",
"tokio 0.1.11",
@ -193,7 +193,7 @@ dependencies = [
"audioipc",
"cubeb-core",
"error-chain",
"futures 0.1.29",
"futures 0.1.31",
"log",
"once_cell",
"slab",
@ -1627,15 +1627,15 @@ checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
[[package]]
name = "futures"
version = "0.1.29"
version = "0.1.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef"
checksum = "3a471a38ef8ed83cd6e40aa59c1ffe17db6855c18e3604d9c4ed8c08ebc28678"
[[package]]
name = "futures"
version = "0.3.12"
version = "0.3.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da9052a1a50244d8d5aa9bf55cbc2fb6f357c86cc52e46c62ed390a7180cf150"
checksum = "0e7e43a803dae2fa37c1f6a8fe121e1f7bf9548b4dfc0522a42f34145dadfc27"
dependencies = [
"futures-channel",
"futures-core",
@ -1647,9 +1647,9 @@ dependencies = [
[[package]]
name = "futures-channel"
version = "0.3.12"
version = "0.3.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2d31b7ec7efab6eefc7c57233bb10b847986139d88cc2f5a02a1ae6871a1846"
checksum = "e682a68b29a882df0545c143dc3646daefe80ba479bcdede94d5a703de2871e2"
dependencies = [
"futures-core",
"futures-sink",
@ -1657,9 +1657,9 @@ dependencies = [
[[package]]
name = "futures-core"
version = "0.3.12"
version = "0.3.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79e5145dde8da7d1b3892dad07a9c98fc04bc39892b1ecc9692cf53e2b780a65"
checksum = "0402f765d8a89a26043b889b26ce3c4679d268fa6bb22cd7c6aad98340e179d1"
[[package]]
name = "futures-cpupool"
@ -1667,37 +1667,35 @@ version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4"
dependencies = [
"futures 0.1.29",
"futures 0.1.31",
"num_cpus",
]
[[package]]
name = "futures-io"
version = "0.3.12"
version = "0.3.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28be053525281ad8259d47e4de5de657b25e7bac113458555bb4b70bc6870500"
checksum = "acc499defb3b348f8d8f3f66415835a9131856ff7714bf10dadfc4ec4bdb29a1"
[[package]]
name = "futures-sink"
version = "0.3.12"
version = "0.3.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "caf5c69029bda2e743fddd0582d1083951d65cc9539aebf8812f36c3491342d6"
checksum = "a57bead0ceff0d6dde8f465ecd96c9338121bb7717d3e7b108059531870c4282"
[[package]]
name = "futures-task"
version = "0.3.12"
version = "0.3.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13de07eb8ea81ae445aca7b69f5f7bf15d7bf4912d8ca37d6645c77ae8a58d86"
dependencies = [
"once_cell",
]
checksum = "8a16bef9fc1a4dddb5bee51c989e3fbba26569cbb0e31f5b303c184e3dd33dae"
[[package]]
name = "futures-util"
version = "0.3.12"
version = "0.3.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "632a8cd0f2a4b3fdea1657f08bde063848c3bd00f9bbf6e256b8be78802e624b"
checksum = "feb5c238d27e2bf94ffdfd27b2c29e3df4a68c4193bb6427384259e2bf191967"
dependencies = [
"autocfg",
"futures-core",
"futures-sink",
"futures-task",
@ -5179,7 +5177,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e93c78d23cc61aa245a8acd2c4a79c4d7fa7fb5c3ca90d5737029f043a84895"
dependencies = [
"bytes 0.4.12",
"futures 0.1.29",
"futures 0.1.31",
"mio",
"tokio-codec",
"tokio-current-thread",
@ -5218,7 +5216,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "881e9645b81c2ce95fcb799ded2c29ffb9f25ef5bef909089a420e5961dd8ccb"
dependencies = [
"bytes 0.4.12",
"futures 0.1.29",
"futures 0.1.31",
"tokio-io",
]
@ -5228,7 +5226,7 @@ version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d16217cad7f1b840c5a97dfb3c43b0c871fef423a6e8d2118c604e843662a443"
dependencies = [
"futures 0.1.29",
"futures 0.1.31",
"tokio-executor",
]
@ -5239,7 +5237,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca6df436c42b0c3330a82d855d2ef017cd793090ad550a6bc2184f4b933532ab"
dependencies = [
"crossbeam-utils 0.6.6",
"futures 0.1.29",
"futures 0.1.31",
]
[[package]]
@ -5248,7 +5246,7 @@ version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5cbe4ca6e71cb0b62a66e4e6f53a8c06a6eefe46cc5f665ad6f274c9906f135"
dependencies = [
"futures 0.1.29",
"futures 0.1.31",
"tokio-io",
"tokio-threadpool",
]
@ -5260,7 +5258,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a5c9635ee806f26d302b8baa1e145689a280d8f5aa8d0552e7344808da54cc21"
dependencies = [
"bytes 0.4.12",
"futures 0.1.29",
"futures 0.1.31",
"log",
]
@ -5270,7 +5268,7 @@ version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8703a5762ff6913510dc64272c714c4389ffd8c4b3cf602879b8bd14ff06b604"
dependencies = [
"futures 0.1.29",
"futures 0.1.31",
"log",
"mio",
"slab",
@ -5285,7 +5283,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b4c329b47f071eb8a746040465fa751bd95e4716e98daef6a9b4e434c17d565"
dependencies = [
"bytes 0.4.12",
"futures 0.1.29",
"futures 0.1.31",
"iovec",
"mio",
"tokio-io",
@ -5301,7 +5299,7 @@ dependencies = [
"crossbeam-deque",
"crossbeam-queue",
"crossbeam-utils 0.6.6",
"futures 0.1.29",
"futures 0.1.31",
"lazy_static",
"log",
"num_cpus",
@ -5316,7 +5314,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2106812d500ed25a4f38235b9cae8f78a09edf43203e16e59c3b769a342a60e"
dependencies = [
"crossbeam-utils 0.6.6",
"futures 0.1.29",
"futures 0.1.31",
"slab",
"tokio-executor",
]
@ -5328,7 +5326,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43eb534af6e8f37d43ab1b612660df14755c42bd003c5f8d2475ee78cc4600c0"
dependencies = [
"bytes 0.4.12",
"futures 0.1.29",
"futures 0.1.31",
"log",
"mio",
"tokio-codec",
@ -5343,7 +5341,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "037ffc3ba0e12a0ab4aca92e5234e0dedeb48fddf6ccd260f1f150a36a9f2445"
dependencies = [
"bytes 0.4.12",
"futures 0.1.29",
"futures 0.1.31",
"iovec",
"libc",
"log",
@ -5598,7 +5596,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "54cd1e2b3eb3539284d88b76a9afcf5e20f2ef2fab74db5b21a1c30d7d945e82"
dependencies = [
"bytes 0.5.6",
"futures 0.3.12",
"futures 0.3.15",
"headers",
"http",
"hyper",

File diff suppressed because one or more lines are too long

View File

@ -1,39 +0,0 @@
environment:
# At the time this was added AppVeyor was having troubles with checking
# revocation of SSL certificates of sites like static.rust-lang.org and what
# we think is crates.io. The libcurl HTTP client by default checks for
# revocation on Windows and according to a mailing list [1] this can be
# disabled.
#
# The `CARGO_HTTP_CHECK_REVOKE` env var here tells cargo to disable SSL
# revocation checking on Windows in libcurl. Note, though, that rustup, which
# we're using to download Rust here, also uses libcurl as the default backend.
# Unlike Cargo, however, rustup doesn't have a mechanism to disable revocation
# checking. To get rustup working we set `RUSTUP_USE_HYPER` which forces it to
# use the Hyper instead of libcurl backend. Both Hyper and libcurl use
# schannel on Windows but it appears that Hyper configures it slightly
# differently such that revocation checking isn't turned on by default.
#
# [1]: https://curl.haxx.se/mail/lib-2016-03/0202.html
RUSTUP_USE_HYPER: 1
CARGO_HTTP_CHECK_REVOKE: false
matrix:
- TARGET: x86_64-pc-windows-msvc
install:
- set PATH=C:\Program Files\Git\mingw64\bin;%PATH%
- curl -sSf -o rustup-init.exe https://win.rustup.rs/
- rustup-init.exe -y --default-host %TARGET%
- set PATH=%PATH%;C:\Users\appveyor\.cargo\bin
- rustc -V
- cargo -V
build: false
test_script:
- cargo build
- cargo build --no-default-features
- cargo test
- cargo test --no-default-features --features use_std
- cargo test --manifest-path futures-cpupool/Cargo.toml

File diff suppressed because one or more lines are too long

View File

@ -12,7 +12,7 @@
[package]
name = "futures"
version = "0.1.29"
version = "0.1.31"
authors = ["Alex Crichton <alex@alexcrichton.com>"]
description = "An implementation of futures and streams featuring zero allocations,\ncomposability, and iterator-like interfaces.\n"
homepage = "https://github.com/rust-lang-nursery/futures-rs"
@ -30,8 +30,3 @@ default = ["use_std", "with-deprecated"]
nightly = []
use_std = []
with-deprecated = []
[badges.appveyor]
repository = "rust-lang-nursery/futures-rs"
[badges.travis-ci]
repository = "rust-lang-nursery/futures-rs"

View File

@ -2,8 +2,7 @@
This library is an implementation of **zero-cost futures** in Rust.
[![Build Status](https://travis-ci.org/rust-lang-nursery/futures-rs.svg?branch=master)](https://travis-ci.org/rust-lang-nursery/futures-rs)
[![Build status](https://ci.appveyor.com/api/projects/status/yl5w3ittk4kggfsh?svg=true)](https://ci.appveyor.com/project/rust-lang-nursery/futures-rs)
[![Build Status](https://img.shields.io/github/workflow/status/rust-lang/futures-rs/CI/master)](https://github.com/rust-lang/futures-rs/actions)
[![Crates.io](https://img.shields.io/crates/v/futures.svg?maxAge=2592000)](https://crates.io/crates/futures)
[Documentation](https://docs.rs/futures)

View File

@ -59,9 +59,8 @@ struct Notifier {
const IDLE: usize = 0;
const POLLING: usize = 1;
const REPOLL: usize = 2;
const COMPLETE: usize = 3;
const POISONED: usize = 4;
const COMPLETE: usize = 2;
const POISONED: usize = 3;
pub fn new<F: Future>(future: F) -> Shared<F> {
Shared {
@ -133,7 +132,7 @@ impl<F> Future for Shared<F>
IDLE => {
// Lock acquired, fall through
}
POLLING | REPOLL => {
POLLING => {
// Another task is currently polling, at this point we just want
// to ensure that our task handle is currently registered
@ -146,56 +145,45 @@ impl<F> Future for Shared<F>
_ => unreachable!(),
}
loop {
struct Reset<'a>(&'a AtomicUsize);
struct Reset<'a>(&'a AtomicUsize);
impl<'a> Drop for Reset<'a> {
fn drop(&mut self) {
use std::thread;
impl<'a> Drop for Reset<'a> {
fn drop(&mut self) {
use std::thread;
if thread::panicking() {
self.0.store(POISONED, SeqCst);
}
if thread::panicking() {
self.0.store(POISONED, SeqCst);
}
}
}
let _reset = Reset(&self.inner.notifier.state);
let _reset = Reset(&self.inner.notifier.state);
// Poll the future
let res = unsafe {
(*self.inner.future.get()).as_mut().unwrap()
.poll_future_notify(&self.inner.notifier, 0)
};
match res {
Ok(Async::NotReady) => {
// Not ready, try to release the handle
match self.inner.notifier.state.compare_and_swap(POLLING, IDLE, SeqCst) {
POLLING => {
// Success
return Ok(Async::NotReady);
}
REPOLL => {
// Gotta poll again!
let prev = self.inner.notifier.state.swap(POLLING, SeqCst);
assert_eq!(prev, REPOLL);
}
_ => unreachable!(),
// Poll the future
let res = unsafe {
(*self.inner.future.get()).as_mut().unwrap()
.poll_future_notify(&self.inner.notifier, 0)
};
match res {
Ok(Async::NotReady) => {
// Not ready, try to release the handle
match self.inner.notifier.state.compare_and_swap(POLLING, IDLE, SeqCst) {
POLLING => {
// Success
return Ok(Async::NotReady);
}
_ => unreachable!(),
}
Ok(Async::Ready(i)) => {
unsafe {
(*self.inner.result.get()) = Some(Ok(SharedItem { item: Arc::new(i) }));
}
break;
}
Ok(Async::Ready(i)) => {
unsafe {
(*self.inner.result.get()) = Some(Ok(SharedItem { item: Arc::new(i) }));
}
Err(e) => {
unsafe {
(*self.inner.result.get()) = Some(Err(SharedError { error: Arc::new(e) }));
}
break;
}
Err(e) => {
unsafe {
(*self.inner.result.get()) = Some(Err(SharedError { error: Arc::new(e) }));
}
}
}
@ -225,8 +213,6 @@ impl<F> Drop for Shared<F> where F: Future {
impl Notify for Notifier {
fn notify(&self, _id: usize) {
self.state.compare_and_swap(POLLING, REPOLL, SeqCst);
let waiters = mem::replace(&mut *self.waiters.lock().unwrap(), HashMap::new());
for (_, waiter) in waiters {
@ -302,6 +288,7 @@ impl<E> fmt::Display for SharedError<E>
impl<E> error::Error for SharedError<E>
where E: error::Error,
{
#[allow(deprecated)]
fn description(&self) -> &str {
self.error.description()
}

View File

@ -157,6 +157,7 @@
#![no_std]
#![deny(missing_docs, missing_debug_implementations)]
#![allow(bare_trait_objects, unknown_lints)]
#![doc(html_root_url = "https://docs.rs/futures/0.1")]
#[macro_use]

View File

@ -91,7 +91,7 @@ impl<T, U> Future for Forward<T, U>
}
loop {
match self.stream_mut()
match self.stream.as_mut()
.expect("Attempted to poll Forward after completion")
.poll()?
{

View File

@ -274,6 +274,26 @@ impl<T> Stream for FuturesUnordered<T>
type Error = T::Error;
fn poll(&mut self) -> Poll<Option<T::Item>, T::Error> {
// Variable to determine how many times it is allowed to poll underlying
// futures without yielding.
//
// A single call to `poll_next` may potentially do a lot of work before
// yielding. This happens in particular if the underlying futures are awoken
// frequently but continue to return `Pending`. This is problematic if other
// tasks are waiting on the executor, since they do not get to run. This value
// caps the number of calls to `poll` on underlying futures a single call to
// `poll_next` is allowed to make.
//
// The value is the length of FuturesUnordered. This ensures that each
// future is polled only once at most per iteration.
//
// See also https://github.com/rust-lang/futures-rs/issues/2047.
let yield_every = self.len();
// Keep track of how many child futures we have polled,
// in case we want to forcibly yield.
let mut polled = 0;
// Ensure `parent` is correctly set.
self.inner.parent.register();
@ -369,12 +389,21 @@ impl<T> Stream for FuturesUnordered<T>
future.poll()
})
};
polled += 1;
let ret = match res {
Ok(Async::NotReady) => {
let node = bomb.node.take().unwrap();
*node.future.get() = Some(future);
bomb.queue.link(node);
if polled == yield_every {
// We have polled a large number of futures in a row without yielding.
// To ensure we do not starve other tasks waiting on the executor,
// we yield here, but immediately wake ourselves up to continue.
task_impl::current().notify();
return Ok(Async::NotReady);
}
continue
}
Ok(Async::Ready(e)) => Ok(Async::Ready(Some(e))),

Some files were not shown because too many files have changed in this diff Show More