Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: webrtc/base/asyncinvoker.h

Issue 2509733003: Rewrite of sigslot that avoids vtables. (Closed)
Patch Set: Going back to tab formatting. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/base/asyncpacketsocket.h » ('j') | webrtc/base/sigslot.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2014 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 162
163 // Similar to AsyncInvoker, but guards against the Thread being destroyed while 163 // Similar to AsyncInvoker, but guards against the Thread being destroyed while
164 // there are outstanding dangling pointers to it. It will connect to the current 164 // there are outstanding dangling pointers to it. It will connect to the current
165 // thread in the constructor, and will get notified when that thread is 165 // thread in the constructor, and will get notified when that thread is
166 // destroyed. After GuardedAsyncInvoker is constructed, it can be used from 166 // destroyed. After GuardedAsyncInvoker is constructed, it can be used from
167 // other threads to post functors to the thread it was constructed on. If that 167 // other threads to post functors to the thread it was constructed on. If that
168 // thread dies, any further calls to AsyncInvoke() will be safely ignored. 168 // thread dies, any further calls to AsyncInvoke() will be safely ignored.
169 class GuardedAsyncInvoker : public sigslot::has_slots<> { 169 class GuardedAsyncInvoker : public sigslot::has_slots<> {
170 public: 170 public:
171 GuardedAsyncInvoker(); 171 GuardedAsyncInvoker();
172 ~GuardedAsyncInvoker() override; 172 ~GuardedAsyncInvoker();
173 173
174 // Synchronously execute all outstanding calls we own, and wait for calls to 174 // Synchronously execute all outstanding calls we own, and wait for calls to
175 // complete before returning. Optionally filter by message id. The destructor 175 // complete before returning. Optionally filter by message id. The destructor
176 // will not wait for outstanding calls, so if that behavior is desired, call 176 // will not wait for outstanding calls, so if that behavior is desired, call
177 // Flush() first. Returns false if the thread has died. 177 // Flush() first. Returns false if the thread has died.
178 bool Flush(uint32_t id = MQID_ANY); 178 bool Flush(uint32_t id = MQID_ANY);
179 179
180 // Call |functor| asynchronously with no callback upon completion. Returns 180 // Call |functor| asynchronously with no callback upon completion. Returns
181 // immediately. Returns false if the thread has died. 181 // immediately. Returns false if the thread has died.
182 template <class ReturnT, class FunctorT> 182 template <class ReturnT, class FunctorT>
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 void ThreadDestroyed(); 246 void ThreadDestroyed();
247 247
248 CriticalSection crit_; 248 CriticalSection crit_;
249 Thread* thread_ GUARDED_BY(crit_); 249 Thread* thread_ GUARDED_BY(crit_);
250 AsyncInvoker invoker_ GUARDED_BY(crit_); 250 AsyncInvoker invoker_ GUARDED_BY(crit_);
251 }; 251 };
252 252
253 } // namespace rtc 253 } // namespace rtc
254 254
255 #endif // WEBRTC_BASE_ASYNCINVOKER_H_ 255 #endif // WEBRTC_BASE_ASYNCINVOKER_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/base/asyncpacketsocket.h » ('j') | webrtc/base/sigslot.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698