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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/base/atomicops.h" 5 #include "src/base/atomicops.h"
6 #include "src/base/platform/platform.h" 6 #include "src/base/platform/platform.h"
7 #include "src/cancelable-task.h" 7 #include "src/cancelable-task.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 10
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 207
208 TEST(CancelableTask, RemoveUnmanagedId) { 208 TEST(CancelableTask, RemoveUnmanagedId) {
209 CancelableTaskManager manager; 209 CancelableTaskManager manager;
210 EXPECT_FALSE(manager.TryAbort(1)); 210 EXPECT_FALSE(manager.TryAbort(1));
211 EXPECT_FALSE(manager.TryAbort(2)); 211 EXPECT_FALSE(manager.TryAbort(2));
212 manager.CancelAndWait(); 212 manager.CancelAndWait();
213 EXPECT_FALSE(manager.TryAbort(1)); 213 EXPECT_FALSE(manager.TryAbort(1));
214 EXPECT_FALSE(manager.TryAbort(3)); 214 EXPECT_FALSE(manager.TryAbort(3));
215 } 215 }
216 216
217 TEST(CancelableTask, EmptyTryAbortAll) {
218 CancelableTaskManager manager;
219 EXPECT_EQ(manager.TryAbortAll(), CancelableTaskManager::kTaskRemoved);
220 }
221
222 TEST(CancelableTask, ThreadedMultipleTasksNotRunTryAbortAll) {
223 CancelableTaskManager manager;
224 ResultType result1 = 0;
225 ResultType result2 = 0;
226 TestTask* task1 = new TestTask(&manager, &result1, TestTask::kCheckNotRun);
227 TestTask* task2 = new TestTask(&manager, &result2, TestTask::kCheckNotRun);
228 ThreadedRunner runner1(task1);
229 ThreadedRunner runner2(task2);
230 EXPECT_EQ(manager.TryAbortAll(), CancelableTaskManager::kTaskAborted);
231 // Tasks are canceled, hence the runner will bail out and not update result.
232 runner1.Start();
233 runner2.Start();
234 runner1.Join();
235 runner2.Join();
236 EXPECT_EQ(GetValue(&result1), 0);
237 EXPECT_EQ(GetValue(&result2), 0);
238 }
239
240 TEST(CancelableTask, ThreadedMultipleTasksStartedTryAbortAll) {
241 CancelableTaskManager manager;
242 ResultType result1 = 0;
243 ResultType result2 = 0;
244 TestTask* task1 =
245 new TestTask(&manager, &result1, TestTask::kWaitTillCanceledAgain);
246 TestTask* task2 =
247 new TestTask(&manager, &result2, TestTask::kWaitTillCanceledAgain);
248 ThreadedRunner runner1(task1);
249 ThreadedRunner runner2(task2);
250 runner1.Start();
251 // Busy wait on result to make sure task1 is done.
252 while (GetValue(&result1) == 0) {
253 }
254 EXPECT_EQ(manager.TryAbortAll(), CancelableTaskManager::kTaskRunning);
255 runner2.Start();
256 runner1.Join();
257 runner2.Join();
258 EXPECT_EQ(GetValue(&result1), 1);
259 EXPECT_EQ(GetValue(&result2), 0);
260 }
261
217 } // namespace internal 262 } // namespace internal
218 } // namespace v8 263 } // namespace v8
OLDNEW
« 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