| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium 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 "platform/WaitableEvent.h" | 5 #include "platform/WaitableEvent.h" |
| 6 | 6 |
| 7 #include "base/synchronization/waitable_event.h" | 7 #include "base/synchronization/waitable_event.h" |
| 8 #include "wtf/PassOwnPtr.h" | 8 #include "wtf/PassOwnPtr.h" |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 WaitableEvent::WaitableEvent(ResetPolicy policy, InitialState state) | 14 WaitableEvent::WaitableEvent(ResetPolicy policy, InitialState state) |
| 15 { | 15 { |
| 16 bool manualReset = policy == ResetPolicy::Manual; | 16 m_impl = adoptPtr(new base::WaitableEvent( |
| 17 bool initiallySignaled = state == InitialState::Signaled; | 17 policy == ResetPolicy::Manual |
| 18 m_impl = adoptPtr(new base::WaitableEvent(manualReset, initiallySignaled)); | 18 ? base::WaitableEvent::ResetPolicy::MANUAL |
| 19 : base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 20 state == InitialState::Signaled |
| 21 ? base::WaitableEvent::InitialState::SIGNALED |
| 22 : base::WaitableEvent::InitialState::NOT_SIGNALED)); |
| 19 } | 23 } |
| 20 | 24 |
| 21 WaitableEvent::~WaitableEvent() {} | 25 WaitableEvent::~WaitableEvent() {} |
| 22 | 26 |
| 23 void WaitableEvent::reset() | 27 void WaitableEvent::reset() |
| 24 { | 28 { |
| 25 m_impl->Reset(); | 29 m_impl->Reset(); |
| 26 } | 30 } |
| 27 | 31 |
| 28 void WaitableEvent::wait() | 32 void WaitableEvent::wait() |
| (...skipping 10 matching lines...) Expand all Loading... |
| 39 { | 43 { |
| 40 std::vector<base::WaitableEvent*> baseEvents; | 44 std::vector<base::WaitableEvent*> baseEvents; |
| 41 for (size_t i = 0; i < events.size(); ++i) | 45 for (size_t i = 0; i < events.size(); ++i) |
| 42 baseEvents.push_back(events[i]->m_impl.get()); | 46 baseEvents.push_back(events[i]->m_impl.get()); |
| 43 size_t idx = base::WaitableEvent::WaitMany(baseEvents.data(), baseEvents.siz
e()); | 47 size_t idx = base::WaitableEvent::WaitMany(baseEvents.data(), baseEvents.siz
e()); |
| 44 DCHECK_LT(idx, events.size()); | 48 DCHECK_LT(idx, events.size()); |
| 45 return idx; | 49 return idx; |
| 46 } | 50 } |
| 47 | 51 |
| 48 } // namespace blink | 52 } // namespace blink |
| OLD | NEW |