diff options
author | Haibo Huang <hhb@google.com> | 2020-05-08 19:26:03 -0700 |
---|---|---|
committer | Chih-Hung Hsieh <chh@google.com> | 2020-05-11 21:13:53 -0700 |
commit | 66a594dcb0ae44ad8d166453fc06504a3fe6588b (patch) | |
tree | e0b71946c7cbfe0f99a7eeafc07c32c0ceb36f61 | |
parent | 3e38deba2a5b538a2aca805cc0c27378e1c5c2d7 (diff) | |
download | futures-task-66a594dcb0ae44ad8d166453fc06504a3fe6588b.tar.gz |
Upgrade rust/crates/futures-task to 0.3.5
* Update Android.bp with new feature and dependent package.
* New dependency of once_cell.
Test: mm in external/rust/crates
Change-Id: Ifb00f1733429665bcab486950d9813055b441a6f
-rw-r--r-- | Android.bp | 7 | ||||
-rw-r--r-- | Cargo.toml | 13 | ||||
-rw-r--r-- | Cargo.toml.orig | 7 | ||||
-rw-r--r-- | METADATA | 12 | ||||
-rw-r--r-- | src/lib.rs | 2 | ||||
-rw-r--r-- | src/noop_waker.rs | 17 |
6 files changed, 39 insertions, 19 deletions
@@ -8,6 +8,13 @@ rust_library_host_rlib { features: [ "alloc", "default", + "once_cell", "std", ], + rlibs: [ + "libonce_cell", + ], } + +// dependent_library ["feature_list"] +// once_cell-1.3.1 "std" @@ -13,21 +13,24 @@ [package] edition = "2018" name = "futures-task" -version = "0.3.4" +version = "0.3.5" authors = ["Alex Crichton <alex@alexcrichton.com>"] description = "Tools for working with tasks.\n" homepage = "https://rust-lang.github.io/futures-rs" -documentation = "https://rust-lang.github.io/futures-api-docs/0.3.0-alpha.18/futures_core" +documentation = "https://docs.rs/futures-task/0.3.5" license = "MIT OR Apache-2.0" repository = "https://github.com/rust-lang/futures-rs" [package.metadata.docs.rs] all-features = true - -[dependencies] +[dependencies.once_cell] +version = "1.3.1" +features = ["std"] +optional = true +default-features = false [features] alloc = [] cfg-target-has-atomic = [] default = ["std"] -std = ["alloc"] +std = ["alloc", "once_cell"] unstable = [] diff --git a/Cargo.toml.orig b/Cargo.toml.orig index 0b4b62a..fdf27ca 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,19 +1,19 @@ [package] name = "futures-task" edition = "2018" -version = "0.3.4" +version = "0.3.5" authors = ["Alex Crichton <alex@alexcrichton.com>"] license = "MIT OR Apache-2.0" repository = "https://github.com/rust-lang/futures-rs" homepage = "https://rust-lang.github.io/futures-rs" -documentation = "https://rust-lang.github.io/futures-api-docs/0.3.0-alpha.18/futures_core" +documentation = "https://docs.rs/futures-task/0.3.5" description = """ Tools for working with tasks. """ [features] default = ["std"] -std = ["alloc"] +std = ["alloc", "once_cell"] alloc = [] # Unstable features @@ -23,6 +23,7 @@ unstable = [] cfg-target-has-atomic = [] [dependencies] +once_cell = { version = "1.3.1", default-features = false, features = ["std"], optional = true } [package.metadata.docs.rs] all-features = true @@ -1,7 +1,5 @@ name: "futures-task" -description: - "Tools for working with tasks." - +description: "Tools for working with tasks." third_party { url { type: HOMEPAGE @@ -11,7 +9,11 @@ third_party { type: GIT value: "https://github.com/rust-lang/futures-rs" } - version: "0.3.4" - last_upgrade_date { year: 2020 month: 3 day: 17 } + version: "0.3.5" license_type: NOTICE + last_upgrade_date { + year: 2020 + month: 5 + day: 8 + } } @@ -11,7 +11,7 @@ #![doc(test(attr(deny(warnings), allow(dead_code, unused_assignments, unused_variables))))] -#![doc(html_root_url = "https://docs.rs/futures-task/0.3.0")] +#![doc(html_root_url = "https://docs.rs/futures-task/0.3.5")] #[cfg(all(feature = "cfg-target-has-atomic", not(feature = "unstable")))] compile_error!("The `cfg-target-has-atomic` feature requires the `unstable` feature as an explicit opt-in to unstable features"); diff --git a/src/noop_waker.rs b/src/noop_waker.rs index a0924ad..2a84bcd 100644 --- a/src/noop_waker.rs +++ b/src/noop_waker.rs @@ -3,7 +3,7 @@ use core::task::{RawWaker, RawWakerVTable, Waker}; use core::ptr::null; #[cfg(feature = "std")] -use core::cell::UnsafeCell; +use once_cell::sync::Lazy; unsafe fn noop_clone(_data: *const ()) -> RawWaker { noop_raw_waker() @@ -47,9 +47,16 @@ pub fn noop_waker() -> Waker { #[inline] #[cfg(feature = "std")] pub fn noop_waker_ref() -> &'static Waker { - thread_local! { - static NOOP_WAKER_INSTANCE: UnsafeCell<Waker> = - UnsafeCell::new(noop_waker()); + static NOOP_WAKER_INSTANCE: Lazy<Waker> = Lazy::new(noop_waker); + &*NOOP_WAKER_INSTANCE +} + +#[cfg(test)] +mod tests { + #[test] + #[cfg(feature = "std")] + fn issue_2091_cross_thread_segfault() { + let waker = std::thread::spawn(super::noop_waker_ref).join().unwrap(); + waker.wake_by_ref(); } - NOOP_WAKER_INSTANCE.with(|l| unsafe { &*l.get() }) } |