| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/os.h" | 5 #include "vm/os.h" |
| 6 #include "vm/thread.h" | 6 #include "vm/thread.h" |
| 7 #include "vm/thread_pool.h" | 7 #include "vm/thread_pool.h" |
| 8 #include "vm/unit_test.h" | 8 #include "vm/unit_test.h" |
| 9 | 9 |
| 10 namespace dart { | 10 namespace dart { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 MonitorLocker ml(&sync); | 56 MonitorLocker ml(&sync); |
| 57 while (!done) { | 57 while (!done) { |
| 58 ml.Wait(); | 58 ml.Wait(); |
| 59 } | 59 } |
| 60 } | 60 } |
| 61 EXPECT(done); | 61 EXPECT(done); |
| 62 | 62 |
| 63 // Do a sanity test on the worker stats. | 63 // Do a sanity test on the worker stats. |
| 64 EXPECT_EQ(1U, thread_pool.workers_started()); | 64 EXPECT_EQ(1U, thread_pool.workers_started()); |
| 65 EXPECT_EQ(0U, thread_pool.workers_stopped()); | 65 EXPECT_EQ(0U, thread_pool.workers_stopped()); |
| 66 EXPECT_EQ(1U, thread_pool.workers_idle()); | |
| 67 EXPECT_EQ(0U, thread_pool.workers_running()); | |
| 68 } | 66 } |
| 69 | 67 |
| 70 | 68 |
| 71 UNIT_TEST_CASE(ThreadPool_RunMany) { | 69 UNIT_TEST_CASE(ThreadPool_RunMany) { |
| 72 const int kTaskCount = 100; | 70 const int kTaskCount = 100; |
| 73 ThreadPool thread_pool; | 71 ThreadPool thread_pool; |
| 74 Monitor sync[kTaskCount]; | 72 Monitor sync[kTaskCount]; |
| 75 bool done[kTaskCount]; | 73 bool done[kTaskCount]; |
| 76 | 74 |
| 77 for (int i = 0; i < kTaskCount; i++) { | 75 for (int i = 0; i < kTaskCount; i++) { |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 MonitorLocker ml(&sync); | 209 MonitorLocker ml(&sync); |
| 212 while (done < kTotalTasks) { | 210 while (done < kTotalTasks) { |
| 213 ml.Wait(); | 211 ml.Wait(); |
| 214 } | 212 } |
| 215 } | 213 } |
| 216 EXPECT_EQ(kTotalTasks, done); | 214 EXPECT_EQ(kTotalTasks, done); |
| 217 } | 215 } |
| 218 | 216 |
| 219 | 217 |
| 220 } // namespace dart | 218 } // namespace dart |
| OLD | NEW |