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

Unified Diff: runtime/bin/thread_pool_test.cc

Issue 9875006: Remove unused thread pool from standalone VM binary. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 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
« no previous file with comments | « runtime/bin/thread_pool.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/thread_pool_test.cc
diff --git a/runtime/bin/thread_pool_test.cc b/runtime/bin/thread_pool_test.cc
deleted file mode 100644
index 2115bee2472559cfb8ed68bd89e7211eea0a6842..0000000000000000000000000000000000000000
--- a/runtime/bin/thread_pool_test.cc
+++ /dev/null
@@ -1,88 +0,0 @@
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-#include "bin/thread_pool.h"
-#include "bin/thread.h"
-#include "platform/assert.h"
-#include "platform/globals.h"
-#include "vm/unit_test.h"
-
-
-UNIT_TEST_CASE(ThreadPoolStartStop) {
- ThreadPool thread_pool(NULL, 10);
- thread_pool.Start();
- thread_pool.Shutdown();
-}
-
-
-static dart::Monitor* monitor = NULL;
-static uint32_t task_count = 0;
-static uint32_t task_sum = 0;
-
-
-void TestTaskHandler(ThreadPool::Task args) {
- MonitorLocker ml(monitor);
- task_count++;
- task_sum += reinterpret_cast<intptr_t>(args);
-}
-
-
-UNIT_TEST_CASE(ThreadPoolTest1) {
- static const uint32_t kNumTestThreads = 10;
- static const uint32_t kNumTestTasks = 1000;
- static const uint32_t kNumLoops = 100;
- monitor = new dart::Monitor();
- ThreadPool thread_pool(&TestTaskHandler, kNumTestThreads);
- uint32_t pool_start_count = 0;
- while (pool_start_count++ < kNumLoops) {
- task_count = 0;
- task_sum = 0;
- thread_pool.Start();
- for (uint32_t i = 1; i <= kNumTestTasks; i++) {
- bool result =
- thread_pool.InsertTask(reinterpret_cast<ThreadPool::Task>(i));
- EXPECT(result);
- }
- thread_pool.Shutdown(ThreadPool::kDrain);
-
- EXPECT_EQ(kNumTestTasks, task_count);
- EXPECT_EQ((1 + kNumTestTasks) * (kNumTestTasks / 2), task_sum);
- }
-
- delete monitor;
- monitor = NULL;
-}
-
-
-UNIT_TEST_CASE(ThreadPoolTest2) {
- static const uint32_t kNumTestThreads = 10;
- static const uint32_t kNumTestTasks = 50000;
- static const uint32_t kNumLoops = 100;
- monitor = new dart::Monitor();
- ThreadPool thread_pool(&TestTaskHandler, kNumTestThreads);
- for (uint32_t i = 1; i <= kNumTestTasks; i++) {
- bool result =
- thread_pool.InsertTask(reinterpret_cast<ThreadPool::Task>(i));
- EXPECT(result);
- }
-
- // Start and stop the thread pool without draining the queue a
- // number of times.
- uint32_t pool_start_count = 0;
- while (pool_start_count++ < kNumLoops) {
- thread_pool.Start();
- dart::OS::Sleep(1);
- thread_pool.Shutdown(ThreadPool::kDoNotDrain);
- }
- // Finally start and drain the queue to get all messages processed.
- thread_pool.Start();
- thread_pool.Shutdown(ThreadPool::kDrain);
-
- // Check that all tasks where processed.
- EXPECT_EQ(kNumTestTasks, task_count);
- EXPECT_EQ((1 + kNumTestTasks) * (kNumTestTasks / 2), task_sum);
-
- delete monitor;
- monitor = NULL;
-}
« no previous file with comments | « runtime/bin/thread_pool.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698