Update ASan/Android runtime and setup script to LLVM r200682.
[chromium-blink-merge.git] / base / synchronization / waitable_event_watcher_win.cc
blob46d47ac581a8e3ff58f6d17a692fe3d5117196ae
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/synchronization/waitable_event_watcher.h"
7 #include "base/compiler_specific.h"
8 #include "base/synchronization/waitable_event.h"
9 #include "base/win/object_watcher.h"
11 namespace base {
13 WaitableEventWatcher::WaitableEventWatcher()
14 : event_(NULL) {
17 WaitableEventWatcher::~WaitableEventWatcher() {
20 bool WaitableEventWatcher::StartWatching(
21 WaitableEvent* event,
22 const EventCallback& callback) {
23 callback_ = callback;
24 event_ = event;
25 return watcher_.StartWatching(event->handle(), this);
28 void WaitableEventWatcher::StopWatching() {
29 callback_.Reset();
30 event_ = NULL;
31 watcher_.StopWatching();
34 WaitableEvent* WaitableEventWatcher::GetWatchedEvent() {
35 return event_;
38 void WaitableEventWatcher::OnObjectSignaled(HANDLE h) {
39 WaitableEvent* event = event_;
40 EventCallback callback = callback_;
41 event_ = NULL;
42 callback_.Reset();
43 DCHECK(event);
45 callback.Run(event);
48 } // namespace base