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 2125113003: Implement SequencedTaskChecker. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addressed comments. Created 4 years, 5 months 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
(Empty)
1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include "webrtc/base/sequenced_task_checker_impl.h"
12
13 #include "webrtc/base/platform_thread.h"
14 #include "webrtc/base/sequenced_task_checker.h"
15
16 namespace rtc {
17
18 SequencedTaskCheckerImpl::SequencedTaskCheckerImpl()
19 : attached_(true), valid_queue_(TaskQueue::Current()) {}
20
21 SequencedTaskCheckerImpl::~SequencedTaskCheckerImpl() {}
22
23 bool SequencedTaskCheckerImpl::CalledSequentially() const {
24 TaskQueue* current_queue = TaskQueue::Current();
25 CritScope scoped_lock(&lock_);
26 if (!attached_) { // true if previously detached.
27 valid_queue_ = current_queue;
28 attached_ = true;
29 }
30 if (!valid_queue_)
31 return thread_checker_.CalledOnValidThread();
32 return valid_queue_ == current_queue;
33 }
34
35 void SequencedTaskCheckerImpl::Detach() {
36 CritScope scoped_lock(&lock_);
37 attached_ = false;
38 valid_queue_ = nullptr;
39 thread_checker_.DetachFromThread();
40 }
41
42 namespace internal {
43
44 SequencedTaskCheckerScope::SequencedTaskCheckerScope(
45 const SequencedTaskChecker* checker) {
46 RTC_DCHECK(checker->CalledSequentially());
47 }
48
49 SequencedTaskCheckerScope::~SequencedTaskCheckerScope() {}
50
51 } // namespace internal
52 } // namespace rtc
OLDNEW
« no previous file with comments | « webrtc/base/sequenced_task_checker_impl.h ('k') | webrtc/base/sequenced_task_checker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698