| 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 #ifndef BASE_SYNCHRONIZATION_WAITABLE_EVENT_WATCHER_H_ | 5 #ifndef BASE_SYNCHRONIZATION_WAITABLE_EVENT_WATCHER_H_ |
| 6 #define BASE_SYNCHRONIZATION_WAITABLE_EVENT_WATCHER_H_ | 6 #define BASE_SYNCHRONIZATION_WAITABLE_EVENT_WATCHER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/base_export.h" |
| 9 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 10 | 11 |
| 11 #if defined(OS_WIN) | 12 #if defined(OS_WIN) |
| 12 #include "base/win/object_watcher.h" | 13 #include "base/win/object_watcher.h" |
| 13 #else | 14 #else |
| 14 #include "base/callback.h" | 15 #include "base/callback.h" |
| 15 #include "base/message_loop.h" | 16 #include "base/message_loop.h" |
| 16 #include "base/synchronization/waitable_event.h" | 17 #include "base/synchronization/waitable_event.h" |
| 17 #endif | 18 #endif |
| 18 | 19 |
| 19 #include "base/base_export.h" | |
| 20 | |
| 21 namespace base { | 20 namespace base { |
| 22 | 21 |
| 23 class Flag; | 22 class Flag; |
| 24 class AsyncWaiter; | 23 class AsyncWaiter; |
| 25 class AsyncCallbackTask; | 24 class AsyncCallbackTask; |
| 26 class WaitableEvent; | 25 class WaitableEvent; |
| 27 | 26 |
| 28 // ----------------------------------------------------------------------------- | 27 // ----------------------------------------------------------------------------- |
| 29 // This class provides a way to wait on a WaitableEvent asynchronously. | 28 // This class provides a way to wait on a WaitableEvent asynchronously. |
| 30 // | 29 // |
| (...skipping 24 matching lines...) Expand all Loading... |
| 55 // BEWARE: With automatically reset WaitableEvents, a signal may be lost if it | 54 // BEWARE: With automatically reset WaitableEvents, a signal may be lost if it |
| 56 // occurs just before a WaitableEventWatcher is deleted. There is currently no | 55 // occurs just before a WaitableEventWatcher is deleted. There is currently no |
| 57 // safe way to stop watching an automatic reset WaitableEvent without possibly | 56 // safe way to stop watching an automatic reset WaitableEvent without possibly |
| 58 // missing a signal. | 57 // missing a signal. |
| 59 // | 58 // |
| 60 // NOTE: you /are/ allowed to delete the WaitableEvent while still waiting on | 59 // NOTE: you /are/ allowed to delete the WaitableEvent while still waiting on |
| 61 // it with a Watcher. It will act as if the event was never signaled. | 60 // it with a Watcher. It will act as if the event was never signaled. |
| 62 // ----------------------------------------------------------------------------- | 61 // ----------------------------------------------------------------------------- |
| 63 | 62 |
| 64 class BASE_EXPORT WaitableEventWatcher | 63 class BASE_EXPORT WaitableEventWatcher |
| 65 #if defined(OS_POSIX) | 64 #if !defined(OS_WIN) |
| 66 : public MessageLoop::DestructionObserver | 65 : public MessageLoop::DestructionObserver |
| 67 #endif | 66 #endif |
| 68 { | 67 { |
| 69 public: | 68 public: |
| 70 | 69 |
| 71 WaitableEventWatcher(); | 70 WaitableEventWatcher(); |
| 72 virtual ~WaitableEventWatcher(); | 71 virtual ~WaitableEventWatcher(); |
| 73 | 72 |
| 74 class BASE_EXPORT Delegate { | 73 class BASE_EXPORT Delegate { |
| 75 public: | 74 public: |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 #endif | 155 #endif |
| 157 | 156 |
| 158 WaitableEvent* event_; | 157 WaitableEvent* event_; |
| 159 | 158 |
| 160 Delegate* delegate_; | 159 Delegate* delegate_; |
| 161 }; | 160 }; |
| 162 | 161 |
| 163 } // namespace base | 162 } // namespace base |
| 164 | 163 |
| 165 #endif // BASE_SYNCHRONIZATION_WAITABLE_EVENT_WATCHER_H_ | 164 #endif // BASE_SYNCHRONIZATION_WAITABLE_EVENT_WATCHER_H_ |
| OLD | NEW |