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

Unified Diff: runtime/vm/thread_barrier_test.cc

Issue 1703383002: - Do not repeatedly allocate and release Monitor objects. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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/vm/thread_barrier.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/thread_barrier_test.cc
diff --git a/runtime/vm/thread_barrier_test.cc b/runtime/vm/thread_barrier_test.cc
index 4517e18d95766079341f680224e62207bd4b1d14..7ca11c64690a7e8f024011f14f5050bb854efa84 100644
--- a/runtime/vm/thread_barrier_test.cc
+++ b/runtime/vm/thread_barrier_test.cc
@@ -46,14 +46,21 @@ UNIT_TEST_CASE(ThreadBarrier) {
static const intptr_t kNumTasks = 5;
static const intptr_t kNumRounds = 500;
- ThreadBarrier barrier(kNumTasks + 1);
- for (intptr_t i = 0; i < kNumTasks; ++i) {
- Dart::thread_pool()->Run(new FuzzTask(kNumRounds, &barrier, i + 1));
- }
- for (intptr_t i = 0; i < kNumRounds; ++i) {
- barrier.Sync();
+ Monitor* monitor = new Monitor();
+ Monitor* monitor_done = new Monitor();
+ {
+ ThreadBarrier barrier(kNumTasks + 1, monitor, monitor_done);
+ for (intptr_t i = 0; i < kNumTasks; ++i) {
+ Dart::thread_pool()->Run(new FuzzTask(kNumRounds, &barrier, i + 1));
+ }
+ for (intptr_t i = 0; i < kNumRounds; ++i) {
+ barrier.Sync();
+ }
+ barrier.Exit();
}
- barrier.Exit();
+
+ delete monitor_done;
+ delete monitor;
}
} // namespace dart
« no previous file with comments | « runtime/vm/thread_barrier.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698