| OLD | NEW |
| 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/lockers.h" | 7 #include "vm/lockers.h" |
| 8 #include "vm/unit_test.h" | 8 #include "vm/unit_test.h" |
| 9 #include "vm/profiler.h" | 9 #include "vm/profiler.h" |
| 10 #include "vm/safepoint.h" | 10 #include "vm/safepoint.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 while (attempts < kNumAttempts) { | 53 while (attempts < kNumAttempts) { |
| 54 MonitorLocker ml(monitor); | 54 MonitorLocker ml(monitor); |
| 55 int64_t start = OS::GetCurrentMonotonicMicros(); | 55 int64_t start = OS::GetCurrentMonotonicMicros(); |
| 56 int64_t wait_time = 2017; | 56 int64_t wait_time = 2017; |
| 57 Monitor::WaitResult wait_result = ml.Wait(wait_time); | 57 Monitor::WaitResult wait_result = ml.Wait(wait_time); |
| 58 int64_t stop = OS::GetCurrentMonotonicMicros(); | 58 int64_t stop = OS::GetCurrentMonotonicMicros(); |
| 59 | 59 |
| 60 // We expect to be timing out here. | 60 // We expect to be timing out here. |
| 61 EXPECT_EQ(Monitor::kTimedOut, wait_result); | 61 EXPECT_EQ(Monitor::kTimedOut, wait_result); |
| 62 | 62 |
| 63 // Check whether this attempt falls within the exptected time limits. | 63 // Check whether this attempt falls within the expected time limits. |
| 64 int64_t wakeup_time = (stop - start) / kMicrosecondsPerMillisecond; | 64 int64_t wakeup_time = (stop - start) / kMicrosecondsPerMillisecond; |
| 65 OS::Print("wakeup_time: %" Pd64 "\n", wakeup_time); | 65 OS::Print("wakeup_time: %" Pd64 "\n", wakeup_time); |
| 66 const int kAcceptableTimeJitter = 20; // Measured in milliseconds. | 66 const int kAcceptableTimeJitter = 20; // Measured in milliseconds. |
| 67 const int kAcceptableWakeupDelay = 150; // Measured in milliseconds. | 67 const int kAcceptableWakeupDelay = 150; // Measured in milliseconds. |
| 68 if (((wait_time - kAcceptableTimeJitter) <= wakeup_time) && | 68 if (((wait_time - kAcceptableTimeJitter) <= wakeup_time) && |
| 69 (wakeup_time <= (wait_time + kAcceptableWakeupDelay))) { | 69 (wakeup_time <= (wait_time + kAcceptableWakeupDelay))) { |
| 70 break; | 70 break; |
| 71 } | 71 } |
| 72 | 72 |
| 73 // Record the attempt. | 73 // Record the attempt. |
| (...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 780 TransitionVMToBlocked transition(thread); | 780 TransitionVMToBlocked transition(thread); |
| 781 MonitorLocker ml(&done_monitor); | 781 MonitorLocker ml(&done_monitor); |
| 782 if (done) { | 782 if (done) { |
| 783 break; | 783 break; |
| 784 } | 784 } |
| 785 } | 785 } |
| 786 } | 786 } |
| 787 } | 787 } |
| 788 | 788 |
| 789 } // namespace dart | 789 } // namespace dart |
| OLD | NEW |