| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/futex-emulation.h" | 5 #include "src/futex-emulation.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "src/base/macros.h" | 9 #include "src/base/macros.h" |
| 10 #include "src/base/platform/time.h" | 10 #include "src/base/platform/time.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 static_cast<double>(std::numeric_limits<int64_t>::max())) { | 94 static_cast<double>(std::numeric_limits<int64_t>::max())) { |
| 95 // 2**63 nanoseconds is 292 years. Let's just treat anything greater as | 95 // 2**63 nanoseconds is 292 years. Let's just treat anything greater as |
| 96 // infinite. | 96 // infinite. |
| 97 use_timeout = false; | 97 use_timeout = false; |
| 98 } else { | 98 } else { |
| 99 rel_timeout = base::TimeDelta::FromNanoseconds( | 99 rel_timeout = base::TimeDelta::FromNanoseconds( |
| 100 static_cast<int64_t>(rel_timeout_ns)); | 100 static_cast<int64_t>(rel_timeout_ns)); |
| 101 } | 101 } |
| 102 } | 102 } |
| 103 | 103 |
| 104 base::Time start_time = base::Time::NowFromSystemTime(); | 104 base::TimeTicks start_time = base::TimeTicks::Now(); |
| 105 base::Time timeout_time = start_time + rel_timeout; | 105 base::TimeTicks timeout_time = start_time + rel_timeout; |
| 106 | 106 |
| 107 wait_list_.Pointer()->AddNode(node); | 107 wait_list_.Pointer()->AddNode(node); |
| 108 | 108 |
| 109 Object* result; | 109 Object* result; |
| 110 | 110 |
| 111 while (true) { | 111 while (true) { |
| 112 base::Time current_time = base::Time::NowFromSystemTime(); | 112 base::TimeTicks current_time = base::TimeTicks::Now(); |
| 113 if (use_timeout && current_time > timeout_time) { | 113 if (use_timeout && current_time > timeout_time) { |
| 114 result = Smi::FromInt(Result::kTimedOut); | 114 result = Smi::FromInt(Result::kTimedOut); |
| 115 break; | 115 break; |
| 116 } | 116 } |
| 117 | 117 |
| 118 base::TimeDelta time_until_timeout = timeout_time - current_time; | 118 base::TimeDelta time_until_timeout = timeout_time - current_time; |
| 119 base::TimeDelta time_to_wait = | 119 base::TimeDelta time_to_wait = |
| 120 (use_timeout && time_until_timeout < kMaxWaitTime) ? time_until_timeout | 120 (use_timeout && time_until_timeout < kMaxWaitTime) ? time_until_timeout |
| 121 : kMaxWaitTime; | 121 : kMaxWaitTime; |
| 122 | 122 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 } | 222 } |
| 223 | 223 |
| 224 node = node->next_; | 224 node = node->next_; |
| 225 } | 225 } |
| 226 | 226 |
| 227 return Smi::FromInt(waiters); | 227 return Smi::FromInt(waiters); |
| 228 } | 228 } |
| 229 | 229 |
| 230 } // namespace internal | 230 } // namespace internal |
| 231 } // namespace v8 | 231 } // namespace v8 |
| OLD | NEW |