Upgrade rust/crates/async-task to 4.2.0 am: 549375c924 am: 5ba6603fdd am: 3e470bf5f7 am: db51179e4b

Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/async-task/+/2133020

Change-Id: Ib853e4c59c1c23d6ee0622b0d52e8599279c6b9c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
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 @@
     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 <stjepang@gmail.com>"]
 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 @@
 # 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 <stjepang@gmail.com>"]
 edition = "2018"
 rust-version = "1.39"
diff --git a/METADATA b/METADATA
index 23c5a33..9a5cdf5 100644
--- a/METADATA
+++ b/METADATA
@@ -7,13 +7,13 @@
   }
   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 @@
         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<T> Drop for Task<T> {