blob: d3daa6f764ca0e243e62ad09897d187cd774a061 [file] [log] [blame]
henrik.lundin@webrtc.org1e3c5c22014-06-16 11:34:44 +00001/*
2 * Copyright (c) 2014 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// Borrowed from Chromium's src/base/threading/thread_checker.h.
12
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020013#ifndef RTC_BASE_THREAD_CHECKER_H_
14#define RTC_BASE_THREAD_CHECKER_H_
henrik.lundin@webrtc.org1e3c5c22014-06-16 11:34:44 +000015
Sebastian Janssondf5e4e02019-03-29 10:34:45 +010016#include "rtc_base/synchronization/sequence_checker.h"
Henrik Kjellanderec78f1c2017-06-29 07:52:50 +020017
18namespace rtc {
Sebastian Janssondf5e4e02019-03-29 10:34:45 +010019// TODO(srte): Replace usages of this with SequenceChecker.
20class ThreadChecker : public webrtc::SequenceChecker {
Henrik Kjellanderec78f1c2017-06-29 07:52:50 +020021 public:
Sebastian Janssondf5e4e02019-03-29 10:34:45 +010022 bool CalledOnValidThread() const { return IsCurrent(); }
23 void DetachFromThread() { Detach(); }
Henrik Kjellanderec78f1c2017-06-29 07:52:50 +020024};
Henrik Kjellanderec78f1c2017-06-29 07:52:50 +020025} // namespace rtc
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020026#endif // RTC_BASE_THREAD_CHECKER_H_