OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 "platform/assert.h" | 5 #include "platform/assert.h" |
6 #include "vm/random.h" | 6 #include "vm/random.h" |
7 #include "vm/thread_barrier.h" | 7 #include "vm/thread_barrier.h" |
8 #include "vm/thread_pool.h" | 8 #include "vm/thread_pool.h" |
9 #include "vm/unit_test.h" | 9 #include "vm/unit_test.h" |
10 | 10 |
11 namespace dart { | 11 namespace dart { |
12 | 12 |
13 class FuzzTask : public ThreadPool::Task { | 13 class FuzzTask : public ThreadPool::Task { |
14 public: | 14 public: |
15 FuzzTask(intptr_t num_rounds, | 15 FuzzTask(intptr_t num_rounds, ThreadBarrier* barrier, uint64_t seed) |
16 ThreadBarrier* barrier, | 16 : num_rounds_(num_rounds), barrier_(barrier), rng_(seed) {} |
17 uint64_t seed) | |
18 : num_rounds_(num_rounds), | |
19 barrier_(barrier), | |
20 rng_(seed) { | |
21 } | |
22 | 17 |
23 virtual void Run() { | 18 virtual void Run() { |
24 for (intptr_t i = 0; i < num_rounds_; ++i) { | 19 for (intptr_t i = 0; i < num_rounds_; ++i) { |
25 RandomSleep(); | 20 RandomSleep(); |
26 barrier_->Sync(); | 21 barrier_->Sync(); |
27 } | 22 } |
28 barrier_->Exit(); | 23 barrier_->Exit(); |
29 } | 24 } |
30 | 25 |
31 private: | 26 private: |
(...skipping 25 matching lines...) Expand all Loading... |
57 barrier.Sync(); | 52 barrier.Sync(); |
58 } | 53 } |
59 barrier.Exit(); | 54 barrier.Exit(); |
60 } | 55 } |
61 | 56 |
62 delete monitor_done; | 57 delete monitor_done; |
63 delete monitor; | 58 delete monitor; |
64 } | 59 } |
65 | 60 |
66 } // namespace dart | 61 } // namespace dart |
OLD | NEW |