From 549375c9248bd9918b7935b0c4168358a23fcdc1 Mon Sep 17 00:00:00 2001 From: David LeGare Date: Wed, 22 Jun 2022 21:36:10 +0000 Subject: Upgrade rust/crates/async-task to 4.2.0 Test: make Change-Id: I9bd204c7a0c0fff8c30be654567e59561b9a7871 --- .cargo_vcs_info.json | 2 +- Android.bp | 2 +- CHANGELOG.md | 4 ++++ Cargo.toml | 16 +++++++++++++--- Cargo.toml.orig | 2 +- METADATA | 8 ++++---- src/task.rs | 13 +++++++++++++ 7 files changed, 37 insertions(+), 10 deletions(-) diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index afec74b..d3b06d7 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,6 +1,6 @@ { "git": { - "sha1": "e6daa4ff3caadb73c7a7ddc40034fb02430ccec8" + "sha1": "de0c79d171e95d1cbbd4becf678cc43ea689551e" }, "path_in_vcs": "" } \ No newline at end of file diff --git a/Android.bp b/Android.bp index 419d97d..8c176c1 100644 --- a/Android.bp +++ b/Android.bp @@ -42,7 +42,7 @@ rust_library { host_supported: true, crate_name: "async_task", cargo_env_compat: true, - cargo_pkg_version: "4.1.0", + cargo_pkg_version: "4.2.0", srcs: ["src/lib.rs"], edition: "2018", features: [ diff --git a/CHANGELOG.md b/CHANGELOG.md index 668bd12..fe87187 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# Version 4.2.0 + +- Add `Task::is_finished`. (#19) + # Version 4.1.0 - Add `FallibleTask`. (#21) diff --git a/Cargo.toml b/Cargo.toml index f563dc6..7847dd8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,14 +13,24 @@ edition = "2018" rust-version = "1.39" name = "async-task" -version = "4.1.0" +version = "4.2.0" authors = ["Stjepan Glavina "] exclude = ["/.*"] description = "Task abstraction for building executors" -keywords = ["futures", "task", "executor", "spawn"] -categories = ["asynchronous", "concurrency", "no-std"] +keywords = [ + "futures", + "task", + "executor", + "spawn", +] +categories = [ + "asynchronous", + "concurrency", + "no-std", +] license = "Apache-2.0 OR MIT" repository = "https://github.com/smol-rs/async-task" + [dev-dependencies.atomic-waker] version = "1" diff --git a/Cargo.toml.orig b/Cargo.toml.orig index b1ae509..7dc7c73 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -3,7 +3,7 @@ name = "async-task" # When publishing a new version: # - Update CHANGELOG.md # - Create "v4.x.y" git tag -version = "4.1.0" +version = "4.2.0" authors = ["Stjepan Glavina "] edition = "2018" rust-version = "1.39" diff --git a/METADATA b/METADATA index 23c5a33..9a5cdf5 100644 --- a/METADATA +++ b/METADATA @@ -7,13 +7,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/async_task/async_task-4.1.0.crate" + value: "https://static.crates.io/crates/async_task/async_task-4.2.0.crate" } - version: "4.1.0" + version: "4.2.0" license_type: NOTICE last_upgrade_date { year: 2022 - month: 3 - day: 1 + month: 6 + day: 22 } } diff --git a/src/task.rs b/src/task.rs index fff918c..7d1c433 100644 --- a/src/task.rs +++ b/src/task.rs @@ -395,6 +395,19 @@ impl Task { let header = ptr as *const Header; unsafe { &*header } } + + /// Returns `true` if the current task is finished. + /// + /// Note that in a multithreaded environment, this task can change finish immediately after calling this function. + pub fn is_finished(&self) -> bool { + let ptr = self.ptr.as_ptr(); + let header = ptr as *const Header; + + unsafe { + let state = (*header).state.load(Ordering::Acquire); + state & (CLOSED | COMPLETED) != 0 + } + } } impl Drop for Task { -- cgit v1.2.3