OLD | NEW |
---|---|
(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 | |
15 namespace rtc { | |
16 | |
17 SequencedTaskCheckerImpl::SequencedTaskCheckerImpl() | |
18 : attached_(true), valid_queu_(TaskQueue::Current()) {} | |
19 | |
20 SequencedTaskCheckerImpl::~SequencedTaskCheckerImpl() {} | |
21 | |
22 bool SequencedTaskCheckerImpl::IsCurrent() const { | |
23 TaskQueue* current_queu = TaskQueue::Current(); | |
tommi
2016/07/08 13:15:15
queue
perkj_webrtc
2016/07/11 08:38:00
Done.
| |
24 CritScope scoped_lock(&lock_); | |
25 if (!attached_) { // true if previously detached. | |
26 valid_queu_ = TaskQueue::Current(); | |
tommi
2016/07/08 13:15:15
valid_queue_ = current_queue;
(since you've alrea
perkj_webrtc
2016/07/11 08:38:00
Done.
| |
27 attached_ = true; | |
28 } | |
29 if (!valid_queu_) | |
30 return thread_checker_.CalledOnValidThread(); | |
31 return valid_queu_ == current_queu; | |
32 } | |
33 | |
34 void SequencedTaskCheckerImpl::Detach() { | |
35 CritScope scoped_lock(&lock_); | |
36 attached_ = false; | |
37 valid_queu_ = nullptr; | |
38 thread_checker_.DetachFromThread(); | |
39 } | |
40 | |
41 } // namespace rtc | |
OLD | NEW |