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

Side by Side Diff: runtime/vm/thread_test.cc

Issue 84813002: Profiling fixes (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/profiler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "platform/assert.h" 5 #include "platform/assert.h"
6 #include "vm/isolate.h" 6 #include "vm/isolate.h"
7 #include "vm/unit_test.h" 7 #include "vm/unit_test.h"
8 #include "vm/signal_handler.h"
8 #include "vm/thread.h" 9 #include "vm/thread.h"
9 10
10 namespace dart { 11 namespace dart {
11 12
12 UNIT_TEST_CASE(Mutex) { 13 UNIT_TEST_CASE(Mutex) {
13 // This unit test case needs a running isolate. 14 // This unit test case needs a running isolate.
14 Isolate* isolate = Isolate::Init(NULL); 15 Isolate* isolate = Isolate::Init(NULL);
15 16
16 Mutex* mutex = new Mutex(); 17 Mutex* mutex = new Mutex();
17 mutex->Lock(); 18 mutex->Lock();
(...skipping 17 matching lines...) Expand all
35 // This unit test case needs a running isolate. 36 // This unit test case needs a running isolate.
36 Isolate* isolate = Isolate::Init(NULL); 37 Isolate* isolate = Isolate::Init(NULL);
37 38
38 Monitor* monitor = new Monitor(); 39 Monitor* monitor = new Monitor();
39 monitor->Enter(); 40 monitor->Enter();
40 monitor->Exit(); 41 monitor->Exit();
41 42
42 const int kNumAttempts = 5; 43 const int kNumAttempts = 5;
43 int attempts = 0; 44 int attempts = 0;
44 while (attempts < kNumAttempts) { 45 while (attempts < kNumAttempts) {
46 // This test verifies that a monitor returns after the specified timeout. If
47 // a signal is delivered to this thread, the monitor may return early.
48 // Block signal delivery in this scope.
49 ScopedSignalBlocker ssb;
45 MonitorLocker ml(monitor); 50 MonitorLocker ml(monitor);
46 int64_t start = OS::GetCurrentTimeMillis(); 51 int64_t start = OS::GetCurrentTimeMillis();
47 int64_t wait_time = 2017; 52 int64_t wait_time = 2017;
48 Monitor::WaitResult wait_result = ml.Wait(wait_time); 53 Monitor::WaitResult wait_result = ml.Wait(wait_time);
49 int64_t stop = OS::GetCurrentTimeMillis(); 54 int64_t stop = OS::GetCurrentTimeMillis();
50 55
51 // We expect to be timing out here. 56 // We expect to be timing out here.
52 EXPECT_EQ(Monitor::kTimedOut, wait_result); 57 EXPECT_EQ(Monitor::kTimedOut, wait_result);
53 58
54 // Check whether this attempt falls within the exptected time limits. 59 // Check whether this attempt falls within the exptected time limits.
(...skipping 12 matching lines...) Expand all
67 EXPECT_LT(attempts, kNumAttempts); 72 EXPECT_LT(attempts, kNumAttempts);
68 73
69 // The isolate shutdown and the destruction of the mutex are out-of-order on 74 // The isolate shutdown and the destruction of the mutex are out-of-order on
70 // purpose. 75 // purpose.
71 isolate->Shutdown(); 76 isolate->Shutdown();
72 delete isolate; 77 delete isolate;
73 delete monitor; 78 delete monitor;
74 } 79 }
75 80
76 } // namespace dart 81 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/profiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698