aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/tests/task.rs
diff options
context:
space:
mode:
authorChris Wailes <chriswailes@google.com>2022-12-12 11:43:41 -0800
committerJeff Vander Stoep <jeffv@google.com>2023-01-18 19:48:52 +0100
commitff62579fde0625f6c8923b58c9dc848c97c680e6 (patch)
treec049adb6c0fca041cbb303c8311c1084e4a832cd /src/runtime/tests/task.rs
parentb669ae94fdcda726d88936d028d35187bf41b016 (diff)
downloadtokio-ff62579fde0625f6c8923b58c9dc848c97c680e6.tar.gz
Upgrade tokio to 1.23.0
This project was upgraded with external_updater. Usage: tools/external_updater/updater.sh update rust/crates/tokio For more info, check https://cs.android.com/android/platform/superproject/+/master:tools/external_updater/README.md Test: TreeHugger Change-Id: Id69553d5e858bddcde0de5b9e72d6bb3c08bafb5
Diffstat (limited to 'src/runtime/tests/task.rs')
-rw-r--r--src/runtime/tests/task.rs50
1 files changed, 47 insertions, 3 deletions
diff --git a/src/runtime/tests/task.rs b/src/runtime/tests/task.rs
index 04e1b56..173e5b0 100644
--- a/src/runtime/tests/task.rs
+++ b/src/runtime/tests/task.rs
@@ -1,5 +1,5 @@
use crate::runtime::blocking::NoopSchedule;
-use crate::runtime::task::{self, unowned, JoinHandle, OwnedTasks, Schedule, Task};
+use crate::runtime::task::{self, unowned, Id, JoinHandle, OwnedTasks, Schedule, Task};
use crate::util::TryLock;
use std::collections::VecDeque;
@@ -55,6 +55,7 @@ fn create_drop1() {
unreachable!()
},
NoopSchedule,
+ Id::next(),
);
drop(notified);
handle.assert_not_dropped();
@@ -71,6 +72,7 @@ fn create_drop2() {
unreachable!()
},
NoopSchedule,
+ Id::next(),
);
drop(join);
handle.assert_not_dropped();
@@ -78,6 +80,46 @@ fn create_drop2() {
handle.assert_dropped();
}
+#[test]
+fn drop_abort_handle1() {
+ let (ad, handle) = AssertDrop::new();
+ let (notified, join) = unowned(
+ async {
+ drop(ad);
+ unreachable!()
+ },
+ NoopSchedule,
+ Id::next(),
+ );
+ let abort = join.abort_handle();
+ drop(join);
+ handle.assert_not_dropped();
+ drop(notified);
+ handle.assert_not_dropped();
+ drop(abort);
+ handle.assert_dropped();
+}
+
+#[test]
+fn drop_abort_handle2() {
+ let (ad, handle) = AssertDrop::new();
+ let (notified, join) = unowned(
+ async {
+ drop(ad);
+ unreachable!()
+ },
+ NoopSchedule,
+ Id::next(),
+ );
+ let abort = join.abort_handle();
+ drop(notified);
+ handle.assert_not_dropped();
+ drop(abort);
+ handle.assert_not_dropped();
+ drop(join);
+ handle.assert_dropped();
+}
+
// Shutting down through Notified works
#[test]
fn create_shutdown1() {
@@ -88,6 +130,7 @@ fn create_shutdown1() {
unreachable!()
},
NoopSchedule,
+ Id::next(),
);
drop(join);
handle.assert_not_dropped();
@@ -104,6 +147,7 @@ fn create_shutdown2() {
unreachable!()
},
NoopSchedule,
+ Id::next(),
);
handle.assert_not_dropped();
notified.shutdown();
@@ -113,7 +157,7 @@ fn create_shutdown2() {
#[test]
fn unowned_poll() {
- let (task, _) = unowned(async {}, NoopSchedule);
+ let (task, _) = unowned(async {}, NoopSchedule, Id::next());
task.run();
}
@@ -228,7 +272,7 @@ impl Runtime {
T: 'static + Send + Future,
T::Output: 'static + Send,
{
- let (handle, notified) = self.0.owned.bind(future, self.clone());
+ let (handle, notified) = self.0.owned.bind(future, self.clone(), Id::next());
if let Some(notified) = notified {
self.schedule(notified);