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(). | |
49 EXPECT_EQ(Monitor::kTimedOut, wait_result); | 48 EXPECT_EQ(Monitor::kTimedOut, wait_result); |
50 const int kAcceptableTimeJitter = 20; // Measured in milliseconds. | 49 const int kAcceptableTimeJitter = 20; // Measured in milliseconds. |
51 EXPECT_LE(wait_time - kAcceptableTimeJitter, stop - start); | 50 EXPECT_LE(wait_time - kAcceptableTimeJitter, stop - start); |
52 const int kAcceptableWakeupDelay = 120; // Measured in milliseconds. | 51 const int kAcceptableWakeupDelay = 120; // Measured in milliseconds. |
53 EXPECT_GE(wait_time + kAcceptableWakeupDelay, stop - start); | 52 EXPECT_GE(wait_time + kAcceptableWakeupDelay, stop - start); |
54 } | 53 } |
55 // The isolate shutdown and the destruction of the mutex are out-of-order on | 54 // The isolate shutdown and the destruction of the mutex are out-of-order on |
56 // purpose. | 55 // purpose. |
57 isolate->Shutdown(); | 56 isolate->Shutdown(); |
58 delete isolate; | 57 delete isolate; |
59 delete monitor; | 58 delete monitor; |
60 } | 59 } |
61 | 60 |
62 } // namespace dart | 61 } // namespace dart |
OLD | NEW |