| 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/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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 int64_t start = OS::GetCurrentTimeMillis(); | 46 int64_t start = OS::GetCurrentTimeMillis(); |
| 47 int64_t wait_time = 2017; | 47 int64_t wait_time = 2017; |
| 48 Monitor::WaitResult wait_result = ml.Wait(wait_time); | 48 Monitor::WaitResult wait_result = ml.Wait(wait_time); |
| 49 int64_t stop = OS::GetCurrentTimeMillis(); | 49 int64_t stop = OS::GetCurrentTimeMillis(); |
| 50 | 50 |
| 51 // We expect to be timing out here. | 51 // We expect to be timing out here. |
| 52 EXPECT_EQ(Monitor::kTimedOut, wait_result); | 52 EXPECT_EQ(Monitor::kTimedOut, wait_result); |
| 53 | 53 |
| 54 // Check whether this attempt falls within the exptected time limits. | 54 // Check whether this attempt falls within the exptected time limits. |
| 55 int64_t wakeup_time = stop - start; | 55 int64_t wakeup_time = stop - start; |
| 56 OS::Print("wakeup_time: %"Pd64"\n", wakeup_time); | 56 OS::Print("wakeup_time: %" Pd64 "\n", wakeup_time); |
| 57 const int kAcceptableTimeJitter = 20; // Measured in milliseconds. | 57 const int kAcceptableTimeJitter = 20; // Measured in milliseconds. |
| 58 const int kAcceptableWakeupDelay = 150; // Measured in milliseconds. | 58 const int kAcceptableWakeupDelay = 150; // Measured in milliseconds. |
| 59 if (((wait_time - kAcceptableTimeJitter) <= wakeup_time) && | 59 if (((wait_time - kAcceptableTimeJitter) <= wakeup_time) && |
| 60 (wakeup_time <= (wait_time + kAcceptableWakeupDelay))) { | 60 (wakeup_time <= (wait_time + kAcceptableWakeupDelay))) { |
| 61 break; | 61 break; |
| 62 } | 62 } |
| 63 | 63 |
| 64 // Record the attempt. | 64 // Record the attempt. |
| 65 attempts++; | 65 attempts++; |
| 66 } | 66 } |
| 67 EXPECT_LT(attempts, kNumAttempts); | 67 EXPECT_LT(attempts, kNumAttempts); |
| 68 | 68 |
| 69 // The isolate shutdown and the destruction of the mutex are out-of-order on | 69 // The isolate shutdown and the destruction of the mutex are out-of-order on |
| 70 // purpose. | 70 // purpose. |
| 71 isolate->Shutdown(); | 71 isolate->Shutdown(); |
| 72 delete isolate; | 72 delete isolate; |
| 73 delete monitor; | 73 delete monitor; |
| 74 } | 74 } |
| 75 | 75 |
| 76 } // namespace dart | 76 } // namespace dart |
| OLD | NEW |