Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Unified Diff: test/unittests/cancelable-tasks-unittest.cc

Issue 2615603002: Implement async AbortAll for the compiler dispatcher (Closed)
Patch Set: updates Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: test/unittests/cancelable-tasks-unittest.cc
diff --git a/test/unittests/cancelable-tasks-unittest.cc b/test/unittests/cancelable-tasks-unittest.cc
index 37690aaf80678f39e799579b285f184296e71d5e..eb5dd915897dc8eba35169f2cb3fb48c9ffc9427 100644
--- a/test/unittests/cancelable-tasks-unittest.cc
+++ b/test/unittests/cancelable-tasks-unittest.cc
@@ -214,5 +214,50 @@ TEST(CancelableTask, RemoveUnmanagedId) {
EXPECT_FALSE(manager.TryAbort(3));
}
+TEST(CancelableTask, EmptyTryAbortAll) {
+ CancelableTaskManager manager;
+ EXPECT_EQ(manager.TryAbortAll(), CancelableTaskManager::kTaskRemoved);
+}
+
+TEST(CancelableTask, ThreadedMultipleTasksNotRunTryAbortAll) {
+ CancelableTaskManager manager;
+ ResultType result1 = 0;
+ ResultType result2 = 0;
+ TestTask* task1 = new TestTask(&manager, &result1, TestTask::kCheckNotRun);
+ TestTask* task2 = new TestTask(&manager, &result2, TestTask::kCheckNotRun);
+ ThreadedRunner runner1(task1);
+ ThreadedRunner runner2(task2);
+ EXPECT_EQ(manager.TryAbortAll(), CancelableTaskManager::kTaskAborted);
+ // Tasks are canceled, hence the runner will bail out and not update result.
+ runner1.Start();
+ runner2.Start();
+ runner1.Join();
+ runner2.Join();
+ EXPECT_EQ(GetValue(&result1), 0);
+ EXPECT_EQ(GetValue(&result2), 0);
+}
+
+TEST(CancelableTask, ThreadedMultipleTasksStartedTryAbortAll) {
+ CancelableTaskManager manager;
+ ResultType result1 = 0;
+ ResultType result2 = 0;
+ TestTask* task1 =
+ new TestTask(&manager, &result1, TestTask::kWaitTillCanceledAgain);
+ TestTask* task2 =
+ new TestTask(&manager, &result2, TestTask::kWaitTillCanceledAgain);
+ ThreadedRunner runner1(task1);
+ ThreadedRunner runner2(task2);
+ runner1.Start();
+ // Busy wait on result to make sure task1 is done.
+ while (GetValue(&result1) == 0) {
+ }
+ EXPECT_EQ(manager.TryAbortAll(), CancelableTaskManager::kTaskRunning);
+ runner2.Start();
+ runner1.Join();
+ runner2.Join();
+ EXPECT_EQ(GetValue(&result1), 1);
+ EXPECT_EQ(GetValue(&result2), 0);
+}
+
} // namespace internal
} // namespace v8
« no previous file with comments | « src/compiler-dispatcher/compiler-dispatcher.cc ('k') | test/unittests/compiler-dispatcher/compiler-dispatcher-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698