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

Side by Side Diff: webrtc/base/sequenced_task_checker_impl.cc

Issue 2464383002: Use queue label as id in SequencedTaskChecker when not running on TaskQueue (Closed)
Patch Set: 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 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
11 #include "webrtc/base/sequenced_task_checker_impl.h" 11 #include "webrtc/base/sequenced_task_checker_impl.h"
12 12
13 #include "webrtc/base/platform_thread.h" 13 #include "webrtc/base/platform_thread.h"
14 #include "webrtc/base/sequenced_task_checker.h" 14 #include "webrtc/base/sequenced_task_checker.h"
15 #include "webrtc/base/task_queue.h" 15 #include "webrtc/base/task_queue.h"
16 16
17 namespace rtc { 17 namespace rtc {
18 18
19 SequencedTaskCheckerImpl::SequencedTaskCheckerImpl() 19 SequencedTaskCheckerImpl::SequencedTaskCheckerImpl()
20 : attached_(true), valid_queue_(TaskQueue::Current()) {} 20 : attached_(true), valid_queue_(TaskQueue::Current()) {}
21 21
22 SequencedTaskCheckerImpl::~SequencedTaskCheckerImpl() {} 22 SequencedTaskCheckerImpl::~SequencedTaskCheckerImpl() {}
23 23
24 bool SequencedTaskCheckerImpl::CalledSequentially() const { 24 bool SequencedTaskCheckerImpl::CalledSequentially() const {
25 TaskQueue* current_queue = TaskQueue::Current(); 25 QueueId current_queue = TaskQueue::Current();
26 #if defined(WEBRTC_MAC)
27 if (current_queue == nullptr)
28 // If we're not running on a TaskQueue, use the system dispatch queue
magjed_webrtc 2016/11/02 12:04:41 nit: I would like the comments above the if-statem
tommi 2016/11/02 16:32:50 agree. style comment: as is, this should use {} si
kthelgason 2016/11/02 16:53:55 Done.
29 // label as an identifier.
30 current_queue = dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL);
magjed_webrtc 2016/11/02 12:04:41 We don't need any include for this magical dispatc
tommi 2016/11/02 16:32:50 good point. We need #include <dispatch/dispatch.h
kthelgason 2016/11/02 16:53:55 Done.
31 #endif
26 CritScope scoped_lock(&lock_); 32 CritScope scoped_lock(&lock_);
27 if (!attached_) { // true if previously detached. 33 if (!attached_) { // true if previously detached.
28 valid_queue_ = current_queue; 34 valid_queue_ = current_queue;
29 attached_ = true; 35 attached_ = true;
30 } 36 }
31 if (!valid_queue_) 37 if (!valid_queue_)
32 return thread_checker_.CalledOnValidThread(); 38 return thread_checker_.CalledOnValidThread();
33 return valid_queue_ == current_queue; 39 return valid_queue_ == current_queue;
34 } 40 }
35 41
36 void SequencedTaskCheckerImpl::Detach() { 42 void SequencedTaskCheckerImpl::Detach() {
37 CritScope scoped_lock(&lock_); 43 CritScope scoped_lock(&lock_);
38 attached_ = false; 44 attached_ = false;
39 valid_queue_ = nullptr; 45 valid_queue_ = nullptr;
40 thread_checker_.DetachFromThread(); 46 thread_checker_.DetachFromThread();
41 } 47 }
42 48
43 namespace internal { 49 namespace internal {
44 50
45 SequencedTaskCheckerScope::SequencedTaskCheckerScope( 51 SequencedTaskCheckerScope::SequencedTaskCheckerScope(
46 const SequencedTaskChecker* checker) { 52 const SequencedTaskChecker* checker) {
47 RTC_DCHECK(checker->CalledSequentially()); 53 RTC_DCHECK(checker->CalledSequentially());
48 } 54 }
49 55
50 SequencedTaskCheckerScope::~SequencedTaskCheckerScope() {} 56 SequencedTaskCheckerScope::~SequencedTaskCheckerScope() {}
51 57
52 } // namespace internal 58 } // namespace internal
53 } // namespace rtc 59 } // namespace rtc
OLDNEW
« webrtc/base/sequenced_task_checker_impl.h ('K') | « webrtc/base/sequenced_task_checker_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698