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

Side by Side Diff: base/synchronization/waitable_event_win.cc

Issue 761903003: Update from https://crrev.com/306655 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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/synchronization/waitable_event.h ('k') | base/test/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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 "base/synchronization/waitable_event.h" 5 #include "base/synchronization/waitable_event.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <windows.h> 8 #include <windows.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/threading/thread_restrictions.h" 11 #include "base/threading/thread_restrictions.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 13
14 namespace base { 14 namespace base {
15 15
16 WaitableEvent::WaitableEvent(bool manual_reset, bool signaled) 16 WaitableEvent::WaitableEvent(bool manual_reset, bool signaled)
17 : handle_(CreateEvent(NULL, manual_reset, signaled, NULL)) { 17 : handle_(CreateEvent(NULL, manual_reset, signaled, NULL)) {
18 // We're probably going to crash anyways if this is ever NULL, so we might as 18 // We're probably going to crash anyways if this is ever NULL, so we might as
19 // well make our stack reports more informative by crashing here. 19 // well make our stack reports more informative by crashing here.
20 CHECK(handle_.IsValid()); 20 CHECK(handle_.IsValid());
21 } 21 }
22 22
23 WaitableEvent::WaitableEvent(HANDLE handle) 23 WaitableEvent::WaitableEvent(win::ScopedHandle handle)
24 : handle_(handle) { 24 : handle_(handle.Pass()) {
25 CHECK(handle_.IsValid()) << "Tried to create WaitableEvent from NULL handle"; 25 CHECK(handle_.IsValid()) << "Tried to create WaitableEvent from NULL handle";
26 } 26 }
27 27
28 WaitableEvent::~WaitableEvent() { 28 WaitableEvent::~WaitableEvent() {
29 } 29 }
30 30
31 HANDLE WaitableEvent::Release() {
32 return handle_.Take();
33 }
34
35 void WaitableEvent::Reset() { 31 void WaitableEvent::Reset() {
36 ResetEvent(handle_.Get()); 32 ResetEvent(handle_.Get());
37 } 33 }
38 34
39 void WaitableEvent::Signal() { 35 void WaitableEvent::Signal() {
40 SetEvent(handle_.Get()); 36 SetEvent(handle_.Get());
41 } 37 }
42 38
43 bool WaitableEvent::IsSignaled() { 39 bool WaitableEvent::IsSignaled() {
44 return TimedWait(TimeDelta::FromMilliseconds(0)); 40 return TimedWait(TimeDelta::FromMilliseconds(0));
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 INFINITE); // no timeout 87 INFINITE); // no timeout
92 if (result >= WAIT_OBJECT_0 + count) { 88 if (result >= WAIT_OBJECT_0 + count) {
93 DPLOG(FATAL) << "WaitForMultipleObjects failed"; 89 DPLOG(FATAL) << "WaitForMultipleObjects failed";
94 return 0; 90 return 0;
95 } 91 }
96 92
97 return result - WAIT_OBJECT_0; 93 return result - WAIT_OBJECT_0;
98 } 94 }
99 95
100 } // namespace base 96 } // namespace base
OLDNEW
« no previous file with comments | « base/synchronization/waitable_event.h ('k') | base/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698