| 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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 | 181 |
| 182 // Spurious wakeup, interrupt or timeout. | 182 // Spurious wakeup, interrupt or timeout. |
| 183 } | 183 } |
| 184 | 184 |
| 185 wait_list_.Pointer()->RemoveNode(node); | 185 wait_list_.Pointer()->RemoveNode(node); |
| 186 node->waiting_ = false; | 186 node->waiting_ = false; |
| 187 | 187 |
| 188 return result; | 188 return result; |
| 189 } | 189 } |
| 190 | 190 |
| 191 | |
| 192 Object* FutexEmulation::Wake(Isolate* isolate, | 191 Object* FutexEmulation::Wake(Isolate* isolate, |
| 193 Handle<JSArrayBuffer> array_buffer, size_t addr, | 192 Handle<JSArrayBuffer> array_buffer, size_t addr, |
| 194 int num_waiters_to_wake) { | 193 double num_waiters_to_wake) { |
| 195 DCHECK(addr < NumberToSize(array_buffer->byte_length())); | 194 DCHECK(addr < NumberToSize(array_buffer->byte_length())); |
| 195 DCHECK(num_waiters_to_wake >= 0); |
| 196 | 196 |
| 197 int waiters_woken = 0; | 197 int waiters_woken = 0; |
| 198 void* backing_store = array_buffer->backing_store(); | 198 void* backing_store = array_buffer->backing_store(); |
| 199 | 199 |
| 200 base::LockGuard<base::Mutex> lock_guard(mutex_.Pointer()); | 200 base::LockGuard<base::Mutex> lock_guard(mutex_.Pointer()); |
| 201 FutexWaitListNode* node = wait_list_.Pointer()->head_; | 201 FutexWaitListNode* node = wait_list_.Pointer()->head_; |
| 202 while (node && num_waiters_to_wake > 0) { | 202 while (node && num_waiters_to_wake > 0) { |
| 203 if (backing_store == node->backing_store_ && addr == node->wait_addr_) { | 203 if (backing_store == node->backing_store_ && addr == node->wait_addr_) { |
| 204 node->waiting_ = false; | 204 node->waiting_ = false; |
| 205 node->cond_.NotifyOne(); | 205 node->cond_.NotifyOne(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 231 } | 231 } |
| 232 | 232 |
| 233 node = node->next_; | 233 node = node->next_; |
| 234 } | 234 } |
| 235 | 235 |
| 236 return Smi::FromInt(waiters); | 236 return Smi::FromInt(waiters); |
| 237 } | 237 } |
| 238 | 238 |
| 239 } // namespace internal | 239 } // namespace internal |
| 240 } // namespace v8 | 240 } // namespace v8 |
| OLD | NEW |