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

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

Issue 2030683005: Remove boolean-based WaitableEvent constructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@chrome_thread_watcher
Patch Set: Created 4 years, 6 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/synchronization/waitable_event.h ('k') | base/synchronization/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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 21 matching lines...) Expand all
32 // the wait-list of many events. An event passes a pointer to itself when 32 // the wait-list of many events. An event passes a pointer to itself when
33 // firing a waiter and so we can store that pointer to find out which event 33 // firing a waiter and so we can store that pointer to find out which event
34 // triggered. 34 // triggered.
35 // ----------------------------------------------------------------------------- 35 // -----------------------------------------------------------------------------
36 36
37 namespace base { 37 namespace base {
38 38
39 // ----------------------------------------------------------------------------- 39 // -----------------------------------------------------------------------------
40 // This is just an abstract base class for waking the two types of waiters 40 // This is just an abstract base class for waking the two types of waiters
41 // ----------------------------------------------------------------------------- 41 // -----------------------------------------------------------------------------
42 WaitableEvent::WaitableEvent(bool manual_reset, bool initially_signaled)
43 : kernel_(new WaitableEventKernel(manual_reset, initially_signaled)) {
44 }
45
46 WaitableEvent::WaitableEvent(ResetPolicy reset_policy, 42 WaitableEvent::WaitableEvent(ResetPolicy reset_policy,
47 InitialState initial_state) 43 InitialState initial_state)
48 : WaitableEvent(reset_policy == ResetPolicy::MANUAL, 44 : kernel_(new WaitableEventKernel(reset_policy, initial_state)) {}
49 initial_state == InitialState::SIGNALED) {}
50 45
51 WaitableEvent::~WaitableEvent() { 46 WaitableEvent::~WaitableEvent() = default;
danakj 2016/06/09 18:25:45 thanks :)
52 }
53 47
54 void WaitableEvent::Reset() { 48 void WaitableEvent::Reset() {
55 base::AutoLock locked(kernel_->lock_); 49 base::AutoLock locked(kernel_->lock_);
56 kernel_->signaled_ = false; 50 kernel_->signaled_ = false;
57 } 51 }
58 52
59 void WaitableEvent::Signal() { 53 void WaitableEvent::Signal() {
60 base::AutoLock locked(kernel_->lock_); 54 base::AutoLock locked(kernel_->lock_);
61 55
62 if (kernel_->signaled_) 56 if (kernel_->signaled_)
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 340
347 return r; 341 return r;
348 } 342 }
349 343
350 // ----------------------------------------------------------------------------- 344 // -----------------------------------------------------------------------------
351 345
352 346
353 // ----------------------------------------------------------------------------- 347 // -----------------------------------------------------------------------------
354 // Private functions... 348 // Private functions...
355 349
356 WaitableEvent::WaitableEventKernel::WaitableEventKernel(bool manual_reset, 350 WaitableEvent::WaitableEventKernel::WaitableEventKernel(
357 bool initially_signaled) 351 ResetPolicy reset_policy,
358 : manual_reset_(manual_reset), 352 InitialState initial_state)
359 signaled_(initially_signaled) { 353 : manual_reset_(reset_policy == ResetPolicy::MANUAL),
360 } 354 signaled_(initial_state == InitialState::SIGNALED) {}
361 355
362 WaitableEvent::WaitableEventKernel::~WaitableEventKernel() { 356 WaitableEvent::WaitableEventKernel::~WaitableEventKernel() = default;
363 }
364 357
365 // ----------------------------------------------------------------------------- 358 // -----------------------------------------------------------------------------
366 // Wake all waiting waiters. Called with lock held. 359 // Wake all waiting waiters. Called with lock held.
367 // ----------------------------------------------------------------------------- 360 // -----------------------------------------------------------------------------
368 bool WaitableEvent::SignalAll() { 361 bool WaitableEvent::SignalAll() {
369 bool signaled_at_least_one = false; 362 bool signaled_at_least_one = false;
370 363
371 for (std::list<Waiter*>::iterator 364 for (std::list<Waiter*>::iterator
372 i = kernel_->waiters_.begin(); i != kernel_->waiters_.end(); ++i) { 365 i = kernel_->waiters_.begin(); i != kernel_->waiters_.end(); ++i) {
373 if ((*i)->Fire(this)) 366 if ((*i)->Fire(this))
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 return true; 406 return true;
414 } 407 }
415 } 408 }
416 409
417 return false; 410 return false;
418 } 411 }
419 412
420 // ----------------------------------------------------------------------------- 413 // -----------------------------------------------------------------------------
421 414
422 } // namespace base 415 } // namespace base
OLDNEW
« no previous file with comments | « base/synchronization/waitable_event.h ('k') | base/synchronization/waitable_event_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698