Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: base/waitable_event_watcher_win.cc

Issue 16554: WaitableEvent (Closed)
Patch Set: Addresssing darin's comments (round 2) Created 11 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/waitable_event_watcher_unittest.cc ('k') | base/waitable_event_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2006-2008 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.
4
5 #include "base/waitable_event_watcher.h"
6
7 #include "base/compiler_specific.h"
8 #include "base/object_watcher.h"
9 #include "base/waitable_event.h"
10
11 namespace base {
12
13 WaitableEventWatcher::ObjectWatcherHelper::ObjectWatcherHelper(
14 WaitableEventWatcher* watcher)
15 : watcher_(watcher) {
16 };
17
18 void WaitableEventWatcher::ObjectWatcherHelper::OnObjectSignaled(HANDLE h) {
19 watcher_->OnObjectSignaled();
20 }
21
22
23 WaitableEventWatcher::WaitableEventWatcher()
24 : event_(NULL),
25 ALLOW_THIS_IN_INITIALIZER_LIST(helper_(this)),
26 delegate_(NULL) {
27 }
28
29 WaitableEventWatcher::~WaitableEventWatcher() {
30 }
31
32 bool WaitableEventWatcher::StartWatching(WaitableEvent* event,
33 Delegate* delegate) {
34 delegate_ = delegate;
35 event_ = event;
36
37 return watcher_.StartWatching(event->handle(), &helper_);
38 }
39
40 void WaitableEventWatcher::StopWatching() {
41 delegate_ = NULL;
42 event_ = NULL;
43 watcher_.StopWatching();
44 }
45
46 WaitableEvent* WaitableEventWatcher::GetWatchedEvent() {
47 return event_;
48 }
49
50 void WaitableEventWatcher::OnObjectSignaled() {
51 WaitableEvent* event = event_;
52 Delegate* delegate = delegate_;
53 event_ = NULL;
54 delegate_ = NULL;
55 DCHECK(event);
56
57 delegate->OnWaitableEventSignaled(event);
58 }
59
60 } // namespace base
OLDNEW
« no previous file with comments | « base/waitable_event_watcher_unittest.cc ('k') | base/waitable_event_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698