OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 // Never call Stop on the current thread. Instead use the inherited Quit | 148 // Never call Stop on the current thread. Instead use the inherited Quit |
149 // function which will exit the base MessageQueue without terminating the | 149 // function which will exit the base MessageQueue without terminating the |
150 // underlying OS thread. | 150 // underlying OS thread. |
151 virtual void Stop(); | 151 virtual void Stop(); |
152 | 152 |
153 // By default, Thread::Run() calls ProcessMessages(kForever). To do other | 153 // By default, Thread::Run() calls ProcessMessages(kForever). To do other |
154 // work, override Run(). To receive and dispatch messages, call | 154 // work, override Run(). To receive and dispatch messages, call |
155 // ProcessMessages occasionally. | 155 // ProcessMessages occasionally. |
156 virtual void Run(); | 156 virtual void Run(); |
157 | 157 |
158 virtual void Send(MessageHandler *phandler, uint32 id = 0, | 158 virtual void Send(MessageHandler* phandler, |
159 MessageData *pdata = NULL); | 159 uint32_t id = 0, |
| 160 MessageData* pdata = NULL); |
160 | 161 |
161 // Convenience method to invoke a functor on another thread. Caller must | 162 // Convenience method to invoke a functor on another thread. Caller must |
162 // provide the |ReturnT| template argument, which cannot (easily) be deduced. | 163 // provide the |ReturnT| template argument, which cannot (easily) be deduced. |
163 // Uses Send() internally, which blocks the current thread until execution | 164 // Uses Send() internally, which blocks the current thread until execution |
164 // is complete. | 165 // is complete. |
165 // Ex: bool result = thread.Invoke<bool>(&MyFunctionReturningBool); | 166 // Ex: bool result = thread.Invoke<bool>(&MyFunctionReturningBool); |
166 // NOTE: This function can only be called when synchronous calls are allowed. | 167 // NOTE: This function can only be called when synchronous calls are allowed. |
167 // See ScopedDisallowBlockingCalls for details. | 168 // See ScopedDisallowBlockingCalls for details. |
168 template <class ReturnT, class FunctorT> | 169 template <class ReturnT, class FunctorT> |
169 ReturnT Invoke(const FunctorT& functor) { | 170 ReturnT Invoke(const FunctorT& functor) { |
170 InvokeBegin(); | 171 InvokeBegin(); |
171 FunctorMessageHandler<ReturnT, FunctorT> handler(functor); | 172 FunctorMessageHandler<ReturnT, FunctorT> handler(functor); |
172 Send(&handler); | 173 Send(&handler); |
173 InvokeEnd(); | 174 InvokeEnd(); |
174 return handler.result(); | 175 return handler.result(); |
175 } | 176 } |
176 | 177 |
177 // From MessageQueue | 178 // From MessageQueue |
178 void Clear(MessageHandler* phandler, | 179 void Clear(MessageHandler* phandler, |
179 uint32 id = MQID_ANY, | 180 uint32_t id = MQID_ANY, |
180 MessageList* removed = NULL) override; | 181 MessageList* removed = NULL) override; |
181 void ReceiveSends() override; | 182 void ReceiveSends() override; |
182 | 183 |
183 // ProcessMessages will process I/O and dispatch messages until: | 184 // ProcessMessages will process I/O and dispatch messages until: |
184 // 1) cms milliseconds have elapsed (returns true) | 185 // 1) cms milliseconds have elapsed (returns true) |
185 // 2) Stop() is called (returns false) | 186 // 2) Stop() is called (returns false) |
186 bool ProcessMessages(int cms); | 187 bool ProcessMessages(int cms); |
187 | 188 |
188 // Returns true if this is a thread that we created using the standard | 189 // Returns true if this is a thread that we created using the standard |
189 // constructor, false if it was created by a call to | 190 // constructor, false if it was created by a call to |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 | 332 |
332 private: | 333 private: |
333 SocketServer* old_ss_; | 334 SocketServer* old_ss_; |
334 | 335 |
335 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(SocketServerScope); | 336 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(SocketServerScope); |
336 }; | 337 }; |
337 | 338 |
338 } // namespace rtc | 339 } // namespace rtc |
339 | 340 |
340 #endif // WEBRTC_BASE_THREAD_H_ | 341 #endif // WEBRTC_BASE_THREAD_H_ |
OLD | NEW |