OLD | NEW |
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 #ifndef BASE_RUN_LOOP_H_ | 5 #ifndef BASE_RUN_LOOP_H_ |
6 #define BASE_RUN_LOOP_H_ | 6 #define BASE_RUN_LOOP_H_ |
7 | 7 |
8 #include "base/base_export.h" | 8 #include "base/base_export.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 // earlier call to Run() when there aren't any tasks or messages in the queue. | 53 // earlier call to Run() when there aren't any tasks or messages in the queue. |
54 // | 54 // |
55 // There can be other nested RunLoops servicing the same task queue | 55 // There can be other nested RunLoops servicing the same task queue |
56 // (MessageLoop); Quitting one RunLoop has no bearing on the others. Quit() | 56 // (MessageLoop); Quitting one RunLoop has no bearing on the others. Quit() |
57 // and QuitWhenIdle() can be called before, during or after Run(). If called | 57 // and QuitWhenIdle() can be called before, during or after Run(). If called |
58 // before Run(), Run() will return immediately when called. Calling Quit() or | 58 // before Run(), Run() will return immediately when called. Calling Quit() or |
59 // QuitWhenIdle() after the RunLoop has already finished running has no | 59 // QuitWhenIdle() after the RunLoop has already finished running has no |
60 // effect. | 60 // effect. |
61 // | 61 // |
62 // WARNING: You must NEVER assume that a call to Quit() or QuitWhenIdle() will | 62 // WARNING: You must NEVER assume that a call to Quit() or QuitWhenIdle() will |
63 // terminate the targetted message loop. If a nested message loop continues | 63 // terminate the targetted message loop. If a nested run loop continues |
64 // running, the target may NEVER terminate. It is very easy to livelock (run | 64 // running, the target may NEVER terminate. It is very easy to livelock (run |
65 // forever) in such a case. | 65 // forever) in such a case. |
66 void Quit(); | 66 void Quit(); |
67 void QuitWhenIdle(); | 67 void QuitWhenIdle(); |
68 | 68 |
69 // Convenience methods to get a closure that safely calls Quit() or | 69 // Convenience methods to get a closure that safely calls Quit() or |
70 // QuitWhenIdle() (has no effect if the RunLoop instance is gone). | 70 // QuitWhenIdle() (has no effect if the RunLoop instance is gone). |
71 // | 71 // |
72 // Example: | 72 // Example: |
73 // RunLoop run_loop; | 73 // RunLoop run_loop; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 | 143 |
144 // WeakPtrFactory for QuitClosure safety. | 144 // WeakPtrFactory for QuitClosure safety. |
145 base::WeakPtrFactory<RunLoop> weak_factory_; | 145 base::WeakPtrFactory<RunLoop> weak_factory_; |
146 | 146 |
147 DISALLOW_COPY_AND_ASSIGN(RunLoop); | 147 DISALLOW_COPY_AND_ASSIGN(RunLoop); |
148 }; | 148 }; |
149 | 149 |
150 } // namespace base | 150 } // namespace base |
151 | 151 |
152 #endif // BASE_RUN_LOOP_H_ | 152 #endif // BASE_RUN_LOOP_H_ |
OLD | NEW |