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

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

Issue 8362026: Fixed a problem with spurious wakeups. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« runtime/vm/thread.h ('K') | « runtime/vm/thread_macos.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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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/assert.h" 5 #include "vm/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/thread.h" 8 #include "vm/thread.h"
9 9
10 namespace dart { 10 namespace dart {
(...skipping 27 matching lines...) Expand all
38 Monitor* monitor = new Monitor(); 38 Monitor* monitor = new Monitor();
39 monitor->Enter(); 39 monitor->Enter();
40 monitor->Exit(); 40 monitor->Exit();
41 41
42 { 42 {
43 MonitorLocker ml(monitor); 43 MonitorLocker ml(monitor);
44 int64_t start = OS::GetCurrentTimeMillis(); 44 int64_t start = OS::GetCurrentTimeMillis();
45 int64_t wait_time = 2017; 45 int64_t wait_time = 2017;
46 Monitor::WaitResult wait_result = ml.Wait(wait_time); 46 Monitor::WaitResult wait_result = ml.Wait(wait_time);
47 int64_t stop = OS::GetCurrentTimeMillis(); 47 int64_t stop = OS::GetCurrentTimeMillis();
48 // Note: This may fail due to spurious wakeups in pthread_cond_wait().
48 EXPECT_EQ(Monitor::kTimedOut, wait_result); 49 EXPECT_EQ(Monitor::kTimedOut, wait_result);
49 const int kAcceptableTimeJitter = 20; // Measured in milliseconds. 50 const int kAcceptableTimeJitter = 20; // Measured in milliseconds.
50 EXPECT_LE(wait_time - kAcceptableTimeJitter, stop - start); 51 EXPECT_LE(wait_time - kAcceptableTimeJitter, stop - start);
51 const int kAcceptableWakeupDelay = 120; // Measured in milliseconds. 52 const int kAcceptableWakeupDelay = 120; // Measured in milliseconds.
52 EXPECT_GE(wait_time + kAcceptableWakeupDelay, stop - start); 53 EXPECT_GE(wait_time + kAcceptableWakeupDelay, stop - start);
53 } 54 }
54 // The isolate shutdown and the destruction of the mutex are out-of-order on 55 // The isolate shutdown and the destruction of the mutex are out-of-order on
55 // purpose. 56 // purpose.
56 isolate->Shutdown(); 57 isolate->Shutdown();
57 delete isolate; 58 delete isolate;
58 delete monitor; 59 delete monitor;
59 } 60 }
60 61
61 } // namespace dart 62 } // namespace dart
OLDNEW
« runtime/vm/thread.h ('K') | « runtime/vm/thread_macos.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698