OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 #ifndef COMPONENTS_SYNC_BASE_SCOPED_EVENT_SIGNAL_H_ |
| 6 #define COMPONENTS_SYNC_BASE_SCOPED_EVENT_SIGNAL_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 |
| 10 namespace base { |
| 11 class WaitableEvent; |
| 12 } |
| 13 |
| 14 namespace syncer { |
| 15 |
| 16 // An object which signals a WaitableEvent when it is deleted. Used to wait for |
| 17 // a task to run or be abandoned. |
| 18 class ScopedEventSignal { |
| 19 public: |
| 20 // |event| will be signaled in the destructor. |
| 21 explicit ScopedEventSignal(base::WaitableEvent* event); |
| 22 |
| 23 // This ScopedEventSignal will signal |other|'s WaitableEvent in its |
| 24 // destructor. |other| will not signal anything in its destructor. The |
| 25 // assignment operator cannot be used if this ScopedEventSignal's |
| 26 // WaitableEvent hasn't been moved to another ScopedEventSignal. |
| 27 ScopedEventSignal(ScopedEventSignal&& other); |
| 28 ScopedEventSignal& operator=(ScopedEventSignal&& other); |
| 29 |
| 30 ~ScopedEventSignal(); |
| 31 |
| 32 private: |
| 33 base::WaitableEvent* event_; |
| 34 |
| 35 DISALLOW_COPY_AND_ASSIGN(ScopedEventSignal); |
| 36 }; |
| 37 |
| 38 } // namespace syncer |
| 39 |
| 40 #endif // COMPONENTS_SYNC_BASE_SCOPED_EVENT_SIGNAL_H_ |
OLD | NEW |