Chromium Code Reviews| OLD | NEW |
|---|---|
| 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_watcher.h" | 5 #include "base/synchronization/waitable_event_watcher.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 36 AutoLock locked(lock_); | 36 AutoLock locked(lock_); |
| 37 flag_ = true; | 37 flag_ = true; |
| 38 } | 38 } |
| 39 | 39 |
| 40 bool value() const { | 40 bool value() const { |
| 41 AutoLock locked(lock_); | 41 AutoLock locked(lock_); |
| 42 return flag_; | 42 return flag_; |
| 43 } | 43 } |
| 44 | 44 |
| 45 private: | 45 private: |
| 46 friend class RefCountedThreadSafe<Flag>; | |
| 47 virtual ~Flag() {} | |
|
jar (doing other things)
2012/04/05 23:04:59
Why bother saying virtual here? You didn't bother
| |
| 48 | |
| 46 mutable Lock lock_; | 49 mutable Lock lock_; |
| 47 bool flag_; | 50 bool flag_; |
| 48 }; | 51 }; |
| 49 | 52 |
| 50 // ----------------------------------------------------------------------------- | 53 // ----------------------------------------------------------------------------- |
| 51 // This is an asynchronous waiter which posts a task to a MessageLoop when | 54 // This is an asynchronous waiter which posts a task to a MessageLoop when |
| 52 // fired. An AsyncWaiter may only be in a single wait-list. | 55 // fired. An AsyncWaiter may only be in a single wait-list. |
| 53 // ----------------------------------------------------------------------------- | 56 // ----------------------------------------------------------------------------- |
| 54 class AsyncWaiter : public WaitableEvent::Waiter { | 57 class AsyncWaiter : public WaitableEvent::Waiter { |
| 55 public: | 58 public: |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 256 // ----------------------------------------------------------------------------- | 259 // ----------------------------------------------------------------------------- |
| 257 // This is called when the MessageLoop which the callback will be run it is | 260 // This is called when the MessageLoop which the callback will be run it is |
| 258 // deleted. We need to cancel the callback as if we had been deleted, but we | 261 // deleted. We need to cancel the callback as if we had been deleted, but we |
| 259 // will still be deleted at some point in the future. | 262 // will still be deleted at some point in the future. |
| 260 // ----------------------------------------------------------------------------- | 263 // ----------------------------------------------------------------------------- |
| 261 void WaitableEventWatcher::WillDestroyCurrentMessageLoop() { | 264 void WaitableEventWatcher::WillDestroyCurrentMessageLoop() { |
| 262 StopWatching(); | 265 StopWatching(); |
| 263 } | 266 } |
| 264 | 267 |
| 265 } // namespace base | 268 } // namespace base |
| OLD | NEW |