Chromium Code Reviews| Index: third_party/WebKit/Source/platform/WaitableEvent.cpp |
| diff --git a/third_party/WebKit/Source/platform/WaitableEvent.cpp b/third_party/WebKit/Source/platform/WaitableEvent.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1c0348fa482f57b81db4949add124663ac8a46c8 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/platform/WaitableEvent.cpp |
| @@ -0,0 +1,46 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "platform/WaitableEvent.h" |
| + |
| +#include "base/synchronization/waitable_event.h" |
| +#include "wtf/PassOwnPtr.h" |
| + |
| +namespace blink { |
| + |
| +WaitableEvent::WaitableEvent(ResetPolicy policy, InitialState state) |
| +{ |
| + const bool manualReset = policy == ResetPolicy::Manual; |
| + const bool initiallySignaled = state == InitialState::Signaled; |
|
esprehn
2016/02/11 01:01:27
we don't usually const locals bools like this
|
| + m_impl = adoptPtr(new base::WaitableEvent(manualReset, initiallySignaled)); |
| +} |
| + |
| +WaitableEvent::~WaitableEvent() {} |
| + |
| +void WaitableEvent::reset() |
| +{ |
| + m_impl->Reset(); |
| +} |
| + |
| +void WaitableEvent::wait() |
| +{ |
| + m_impl->Wait(); |
| +} |
| + |
| +void WaitableEvent::signal() |
| +{ |
| + m_impl->Signal(); |
| +} |
| + |
| +size_t WaitableEvent::waitMultiple(const WTF::Vector<WaitableEvent*>& events) |
| +{ |
| + std::vector<base::WaitableEvent*> baseEvents; |
| + for (size_t i = 0; i < events.size(); ++i) |
| + baseEvents.push_back(events[i]->m_impl.get()); |
| + size_t idx = base::WaitableEvent::WaitMany(baseEvents.data(), baseEvents.size()); |
| + DCHECK_LT(idx, events.size()); |
| + return idx; |
| +} |
| + |
| +} // namespace blink |