/* * Copyright 2004 The WebRTC Project Authors. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #ifndef RTC_BASE_THREAD_H_ #define RTC_BASE_THREAD_H_ #include <stdint.h> #include <list> #include <map> #include <memory> #include <queue> #include <set> #include <string> #include <type_traits> #include <utility> #include <vector> #include "absl/strings/string_view.h" #if defined(WEBRTC_POSIX) #include <pthread.h> #endif #include "absl/base/attributes.h" #include "absl/functional/any_invocable.h" #include "api/function_view.h" #include "api/location.h" #include "api/task_queue/task_queue_base.h" #include "api/units/time_delta.h" #include "rtc_base/checks.h" #include "rtc_base/platform_thread_types.h" #include "rtc_base/socket_server.h" #include "rtc_base/synchronization/mutex.h" #include "rtc_base/system/rtc_export.h" #include "rtc_base/thread_annotations.h" #if defined(WEBRTC_WIN) #include "rtc_base/win32.h" #endif #if RTC_DCHECK_IS_ON // Counts how many `Thread::BlockingCall` are made from within a scope and logs // the number of blocking calls at the end of the scope. #define RTC_LOG_THREAD_BLOCK_COUNT() … // Adds an RTC_DCHECK_LE that checks that the number of blocking calls are // less than or equal to a specific value. Use to avoid regressing in the // number of blocking thread calls. // Note: Use of this macro, requires RTC_LOG_THREAD_BLOCK_COUNT() to be called // first. #define RTC_DCHECK_BLOCK_COUNT_NO_MORE_THAN(x) … #else #define RTC_LOG_THREAD_BLOCK_COUNT … #define RTC_DCHECK_BLOCK_COUNT_NO_MORE_THAN … #endif namespace rtc { class Thread; class RTC_EXPORT ThreadManager { … }; // WARNING! SUBCLASSES MUST CALL Stop() IN THEIR DESTRUCTORS! See ~Thread(). class RTC_LOCKABLE RTC_EXPORT Thread : public webrtc::TaskQueueBase { … }; // AutoThread automatically installs itself at construction // uninstalls at destruction, if a Thread object is // _not already_ associated with the current OS thread. // // NOTE: *** This class should only be used by tests *** // class AutoThread : public Thread { … }; // AutoSocketServerThread automatically installs itself at // construction and uninstalls at destruction. If a Thread object is // already associated with the current OS thread, it is temporarily // disassociated and restored by the destructor. class AutoSocketServerThread : public Thread { … }; } // namespace rtc #endif // RTC_BASE_THREAD_H_