OLD | NEW |
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 Loading... |
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 |
OLD | NEW |