Rename CriticalSection to RecursiveCriticalSection.
This name change communicates that the recursive critical section should not be used for new code. The relevant files are renamed rtc_base/critical_section* -> rtc_base/deprecated/recursive_critical_section* Bug: webrtc:11567 Change-Id: I73483a1c5e59c389407a981efbfc2cfe76ccdb43 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/179483 Commit-Queue: Markus Handell <handellm@webrtc.org> Reviewed-by: Niels Moller <nisse@webrtc.org> Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Reviewed-by: Tommi <tommi@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31754}
This commit is contained in:
committed by
Commit Bot
parent
1a09faed62
commit
3cb525b378
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
#include "call/rtp_demuxer.h"
|
#include "call/rtp_demuxer.h"
|
||||||
#include "call/rtp_stream_receiver_controller_interface.h"
|
#include "call/rtp_stream_receiver_controller_interface.h"
|
||||||
#include "rtc_base/critical_section.h"
|
#include "rtc_base/deprecated/recursive_critical_section.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ class RtpStreamReceiverController
|
|||||||
// to be called on the same thread, and OnRtpPacket to be called
|
// to be called on the same thread, and OnRtpPacket to be called
|
||||||
// by a single, but possibly distinct, thread. But applications not
|
// by a single, but possibly distinct, thread. But applications not
|
||||||
// using Call may have use threads differently.
|
// using Call may have use threads differently.
|
||||||
rtc::CriticalSection lock_;
|
rtc::RecursiveCriticalSection lock_;
|
||||||
RtpDemuxer demuxer_ RTC_GUARDED_BY(&lock_);
|
RtpDemuxer demuxer_ RTC_GUARDED_BY(&lock_);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -25,7 +25,7 @@
|
|||||||
#include "modules/desktop_capture/win/dxgi_adapter_duplicator.h"
|
#include "modules/desktop_capture/win/dxgi_adapter_duplicator.h"
|
||||||
#include "modules/desktop_capture/win/dxgi_context.h"
|
#include "modules/desktop_capture/win/dxgi_context.h"
|
||||||
#include "modules/desktop_capture/win/dxgi_frame.h"
|
#include "modules/desktop_capture/win/dxgi_frame.h"
|
||||||
#include "rtc_base/critical_section.h"
|
#include "rtc_base/deprecated/recursive_critical_section.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
@ -219,7 +219,7 @@ class DxgiDuplicatorController {
|
|||||||
std::atomic_int refcount_;
|
std::atomic_int refcount_;
|
||||||
|
|
||||||
// This lock must be locked whenever accessing any of the following objects.
|
// This lock must be locked whenever accessing any of the following objects.
|
||||||
rtc::CriticalSection lock_;
|
rtc::RecursiveCriticalSection lock_;
|
||||||
|
|
||||||
// A self-incremented integer to compare with the one in Context. It ensures
|
// A self-incremented integer to compare with the one in Context. It ensures
|
||||||
// a Context instance is always initialized after DxgiDuplicatorController.
|
// a Context instance is always initialized after DxgiDuplicatorController.
|
||||||
|
|||||||
@ -32,7 +32,7 @@
|
|||||||
#include "modules/rtp_rtcp/include/rtp_packet_sender.h"
|
#include "modules/rtp_rtcp/include/rtp_packet_sender.h"
|
||||||
#include "modules/rtp_rtcp/source/rtp_packet_to_send.h"
|
#include "modules/rtp_rtcp/source/rtp_packet_to_send.h"
|
||||||
#include "modules/utility/include/process_thread.h"
|
#include "modules/utility/include/process_thread.h"
|
||||||
#include "rtc_base/critical_section.h"
|
#include "rtc_base/deprecated/recursive_critical_section.h"
|
||||||
#include "rtc_base/thread_annotations.h"
|
#include "rtc_base/thread_annotations.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
@ -157,7 +157,7 @@ class PacedSender : public Module,
|
|||||||
PacedSender* const delegate_;
|
PacedSender* const delegate_;
|
||||||
} module_proxy_{this};
|
} module_proxy_{this};
|
||||||
|
|
||||||
rtc::CriticalSection critsect_;
|
rtc::RecursiveCriticalSection critsect_;
|
||||||
const PacingController::ProcessMode process_mode_;
|
const PacingController::ProcessMode process_mode_;
|
||||||
PacingController pacing_controller_ RTC_GUARDED_BY(critsect_);
|
PacingController pacing_controller_ RTC_GUARDED_BY(critsect_);
|
||||||
|
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
#include "api/task_queue/queued_task.h"
|
#include "api/task_queue/queued_task.h"
|
||||||
#include "modules/include/module.h"
|
#include "modules/include/module.h"
|
||||||
#include "modules/utility/include/process_thread.h"
|
#include "modules/utility/include/process_thread.h"
|
||||||
#include "rtc_base/critical_section.h"
|
#include "rtc_base/deprecated/recursive_critical_section.h"
|
||||||
#include "rtc_base/event.h"
|
#include "rtc_base/event.h"
|
||||||
#include "rtc_base/location.h"
|
#include "rtc_base/location.h"
|
||||||
#include "rtc_base/platform_thread.h"
|
#include "rtc_base/platform_thread.h"
|
||||||
@ -92,7 +92,8 @@ class ProcessThreadImpl : public ProcessThread {
|
|||||||
// issues, but I haven't figured out what they are, if there are alignment
|
// issues, but I haven't figured out what they are, if there are alignment
|
||||||
// requirements for mutexes on Mac or if there's something else to it.
|
// requirements for mutexes on Mac or if there's something else to it.
|
||||||
// So be careful with changing the layout.
|
// So be careful with changing the layout.
|
||||||
rtc::CriticalSection lock_; // Used to guard modules_, tasks_ and stop_.
|
rtc::RecursiveCriticalSection
|
||||||
|
lock_; // Used to guard modules_, tasks_ and stop_.
|
||||||
|
|
||||||
rtc::ThreadChecker thread_checker_;
|
rtc::ThreadChecker thread_checker_;
|
||||||
rtc::Event wake_up_;
|
rtc::Event wake_up_;
|
||||||
|
|||||||
@ -316,7 +316,7 @@ class JsepTransport : public sigslot::has_slots<> {
|
|||||||
const rtc::Thread* const network_thread_;
|
const rtc::Thread* const network_thread_;
|
||||||
// Critical scope for fields accessed off-thread
|
// Critical scope for fields accessed off-thread
|
||||||
// TODO(https://bugs.webrtc.org/10300): Stop doing this.
|
// TODO(https://bugs.webrtc.org/10300): Stop doing this.
|
||||||
rtc::CriticalSection accessor_lock_;
|
rtc::RecursiveCriticalSection accessor_lock_;
|
||||||
const std::string mid_;
|
const std::string mid_;
|
||||||
// needs-ice-restart bit as described in JSEP.
|
// needs-ice-restart bit as described in JSEP.
|
||||||
bool needs_ice_restart_ RTC_GUARDED_BY(accessor_lock_) = false;
|
bool needs_ice_restart_ RTC_GUARDED_BY(accessor_lock_) = false;
|
||||||
|
|||||||
@ -170,8 +170,8 @@ rtc_source_set("refcount") {
|
|||||||
|
|
||||||
rtc_library("criticalsection") {
|
rtc_library("criticalsection") {
|
||||||
sources = [
|
sources = [
|
||||||
"critical_section.cc",
|
"deprecated/recursive_critical_section.cc",
|
||||||
"critical_section.h",
|
"deprecated/recursive_critical_section.h",
|
||||||
]
|
]
|
||||||
deps = [
|
deps = [
|
||||||
":atomicops",
|
":atomicops",
|
||||||
@ -179,7 +179,6 @@ rtc_library("criticalsection") {
|
|||||||
":macromagic",
|
":macromagic",
|
||||||
":platform_thread_types",
|
":platform_thread_types",
|
||||||
"synchronization:yield",
|
"synchronization:yield",
|
||||||
"system:rtc_export",
|
|
||||||
"system:unused",
|
"system:unused",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -1181,7 +1180,7 @@ if (rtc_include_tests) {
|
|||||||
"byte_order_unittest.cc",
|
"byte_order_unittest.cc",
|
||||||
"checks_unittest.cc",
|
"checks_unittest.cc",
|
||||||
"copy_on_write_buffer_unittest.cc",
|
"copy_on_write_buffer_unittest.cc",
|
||||||
"critical_section_unittest.cc",
|
"deprecated/recursive_critical_section_unittest.cc",
|
||||||
"event_tracer_unittest.cc",
|
"event_tracer_unittest.cc",
|
||||||
"event_unittest.cc",
|
"event_unittest.cc",
|
||||||
"logging_unittest.cc",
|
"logging_unittest.cc",
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
* be found in the AUTHORS file in the root of the source tree.
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "rtc_base/critical_section.h"
|
#include "rtc_base/deprecated/recursive_critical_section.h"
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
@ -18,8 +18,6 @@
|
|||||||
#include "rtc_base/synchronization/yield.h"
|
#include "rtc_base/synchronization/yield.h"
|
||||||
#include "rtc_base/system/unused.h"
|
#include "rtc_base/system/unused.h"
|
||||||
|
|
||||||
// TODO(tommi): Split this file up to per-platform implementation files.
|
|
||||||
|
|
||||||
#if RTC_DCHECK_IS_ON
|
#if RTC_DCHECK_IS_ON
|
||||||
#define RTC_CS_DEBUG_CODE(x) x
|
#define RTC_CS_DEBUG_CODE(x) x
|
||||||
#else // !RTC_DCHECK_IS_ON
|
#else // !RTC_DCHECK_IS_ON
|
||||||
@ -28,7 +26,7 @@
|
|||||||
|
|
||||||
namespace rtc {
|
namespace rtc {
|
||||||
|
|
||||||
CriticalSection::CriticalSection() {
|
RecursiveCriticalSection::RecursiveCriticalSection() {
|
||||||
#if defined(WEBRTC_WIN)
|
#if defined(WEBRTC_WIN)
|
||||||
InitializeCriticalSection(&crit_);
|
InitializeCriticalSection(&crit_);
|
||||||
#elif defined(WEBRTC_POSIX)
|
#elif defined(WEBRTC_POSIX)
|
||||||
@ -57,7 +55,7 @@ CriticalSection::CriticalSection() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
CriticalSection::~CriticalSection() {
|
RecursiveCriticalSection::~RecursiveCriticalSection() {
|
||||||
#if defined(WEBRTC_WIN)
|
#if defined(WEBRTC_WIN)
|
||||||
DeleteCriticalSection(&crit_);
|
DeleteCriticalSection(&crit_);
|
||||||
#elif defined(WEBRTC_POSIX)
|
#elif defined(WEBRTC_POSIX)
|
||||||
@ -71,7 +69,7 @@ CriticalSection::~CriticalSection() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void CriticalSection::Enter() const RTC_EXCLUSIVE_LOCK_FUNCTION() {
|
void RecursiveCriticalSection::Enter() const RTC_EXCLUSIVE_LOCK_FUNCTION() {
|
||||||
#if defined(WEBRTC_WIN)
|
#if defined(WEBRTC_WIN)
|
||||||
EnterCriticalSection(&crit_);
|
EnterCriticalSection(&crit_);
|
||||||
#elif defined(WEBRTC_POSIX)
|
#elif defined(WEBRTC_POSIX)
|
||||||
@ -130,7 +128,8 @@ void CriticalSection::Enter() const RTC_EXCLUSIVE_LOCK_FUNCTION() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CriticalSection::TryEnter() const RTC_EXCLUSIVE_TRYLOCK_FUNCTION(true) {
|
bool RecursiveCriticalSection::TryEnter() const
|
||||||
|
RTC_EXCLUSIVE_TRYLOCK_FUNCTION(true) {
|
||||||
#if defined(WEBRTC_WIN)
|
#if defined(WEBRTC_WIN)
|
||||||
return TryEnterCriticalSection(&crit_) != FALSE;
|
return TryEnterCriticalSection(&crit_) != FALSE;
|
||||||
#elif defined(WEBRTC_POSIX)
|
#elif defined(WEBRTC_POSIX)
|
||||||
@ -163,7 +162,7 @@ bool CriticalSection::TryEnter() const RTC_EXCLUSIVE_TRYLOCK_FUNCTION(true) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void CriticalSection::Leave() const RTC_UNLOCK_FUNCTION() {
|
void RecursiveCriticalSection::Leave() const RTC_UNLOCK_FUNCTION() {
|
||||||
RTC_DCHECK(CurrentThreadIsOwner());
|
RTC_DCHECK(CurrentThreadIsOwner());
|
||||||
#if defined(WEBRTC_WIN)
|
#if defined(WEBRTC_WIN)
|
||||||
LeaveCriticalSection(&crit_);
|
LeaveCriticalSection(&crit_);
|
||||||
@ -191,7 +190,7 @@ void CriticalSection::Leave() const RTC_UNLOCK_FUNCTION() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CriticalSection::CurrentThreadIsOwner() const {
|
bool RecursiveCriticalSection::CurrentThreadIsOwner() const {
|
||||||
#if defined(WEBRTC_WIN)
|
#if defined(WEBRTC_WIN)
|
||||||
// OwningThread has type HANDLE but actually contains the Thread ID:
|
// OwningThread has type HANDLE but actually contains the Thread ID:
|
||||||
// http://stackoverflow.com/questions/12675301/why-is-the-owningthread-member-of-critical-section-of-type-handle-when-it-is-de
|
// http://stackoverflow.com/questions/12675301/why-is-the-owningthread-member-of-critical-section-of-type-handle-when-it-is-de
|
||||||
@ -210,7 +209,7 @@ bool CriticalSection::CurrentThreadIsOwner() const {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
CritScope::CritScope(const CriticalSection* cs) : cs_(cs) {
|
CritScope::CritScope(const RecursiveCriticalSection* cs) : cs_(cs) {
|
||||||
cs_->Enter();
|
cs_->Enter();
|
||||||
}
|
}
|
||||||
CritScope::~CritScope() {
|
CritScope::~CritScope() {
|
||||||
@ -8,13 +8,11 @@
|
|||||||
* be found in the AUTHORS file in the root of the source tree.
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef RTC_BASE_CRITICAL_SECTION_H_
|
#ifndef RTC_BASE_DEPRECATED_RECURSIVE_CRITICAL_SECTION_H_
|
||||||
#define RTC_BASE_CRITICAL_SECTION_H_
|
#define RTC_BASE_DEPRECATED_RECURSIVE_CRITICAL_SECTION_H_
|
||||||
|
|
||||||
#include "rtc_base/checks.h"
|
|
||||||
#include "rtc_base/constructor_magic.h"
|
#include "rtc_base/constructor_magic.h"
|
||||||
#include "rtc_base/platform_thread_types.h"
|
#include "rtc_base/platform_thread_types.h"
|
||||||
#include "rtc_base/system/rtc_export.h"
|
|
||||||
#include "rtc_base/thread_annotations.h"
|
#include "rtc_base/thread_annotations.h"
|
||||||
|
|
||||||
#if defined(WEBRTC_WIN)
|
#if defined(WEBRTC_WIN)
|
||||||
@ -43,13 +41,18 @@
|
|||||||
|
|
||||||
namespace rtc {
|
namespace rtc {
|
||||||
|
|
||||||
|
// NOTE: This class is deprecated. Please use webrtc::Mutex instead!
|
||||||
|
// Search using https://www.google.com/?q=recursive+lock+considered+harmful
|
||||||
|
// to find the reasons.
|
||||||
|
//
|
||||||
// Locking methods (Enter, TryEnter, Leave)are const to permit protecting
|
// Locking methods (Enter, TryEnter, Leave)are const to permit protecting
|
||||||
// members inside a const context without requiring mutable CriticalSections
|
// members inside a const context without requiring mutable
|
||||||
// everywhere. CriticalSection is reentrant lock.
|
// RecursiveCriticalSections everywhere. RecursiveCriticalSection is
|
||||||
class RTC_LOCKABLE RTC_EXPORT CriticalSection {
|
// reentrant lock.
|
||||||
|
class RTC_LOCKABLE RecursiveCriticalSection {
|
||||||
public:
|
public:
|
||||||
CriticalSection();
|
RecursiveCriticalSection();
|
||||||
~CriticalSection();
|
~RecursiveCriticalSection();
|
||||||
|
|
||||||
void Enter() const RTC_EXCLUSIVE_LOCK_FUNCTION();
|
void Enter() const RTC_EXCLUSIVE_LOCK_FUNCTION();
|
||||||
bool TryEnter() const RTC_EXCLUSIVE_TRYLOCK_FUNCTION(true);
|
bool TryEnter() const RTC_EXCLUSIVE_TRYLOCK_FUNCTION(true);
|
||||||
@ -87,14 +90,15 @@ class RTC_LOCKABLE RTC_EXPORT CriticalSection {
|
|||||||
// CritScope, for serializing execution through a scope.
|
// CritScope, for serializing execution through a scope.
|
||||||
class RTC_SCOPED_LOCKABLE CritScope {
|
class RTC_SCOPED_LOCKABLE CritScope {
|
||||||
public:
|
public:
|
||||||
explicit CritScope(const CriticalSection* cs) RTC_EXCLUSIVE_LOCK_FUNCTION(cs);
|
explicit CritScope(const RecursiveCriticalSection* cs)
|
||||||
|
RTC_EXCLUSIVE_LOCK_FUNCTION(cs);
|
||||||
~CritScope() RTC_UNLOCK_FUNCTION();
|
~CritScope() RTC_UNLOCK_FUNCTION();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const CriticalSection* const cs_;
|
const RecursiveCriticalSection* const cs_;
|
||||||
RTC_DISALLOW_COPY_AND_ASSIGN(CritScope);
|
RTC_DISALLOW_COPY_AND_ASSIGN(CritScope);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace rtc
|
} // namespace rtc
|
||||||
|
|
||||||
#endif // RTC_BASE_CRITICAL_SECTION_H_
|
#endif // RTC_BASE_DEPRECATED_RECURSIVE_CRITICAL_SECTION_H_
|
||||||
@ -8,7 +8,7 @@
|
|||||||
* be found in the AUTHORS file in the root of the source tree.
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "rtc_base/critical_section.h"
|
#include "rtc_base/deprecated/recursive_critical_section.h"
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@ -124,7 +124,7 @@ class RTC_LOCKABLE CriticalSectionLock {
|
|||||||
void Unlock() RTC_UNLOCK_FUNCTION() { cs_.Leave(); }
|
void Unlock() RTC_UNLOCK_FUNCTION() { cs_.Leave(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CriticalSection cs_;
|
RecursiveCriticalSection cs_;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class Lock>
|
template <class Lock>
|
||||||
@ -183,7 +183,7 @@ class AtomicOpRunner : public RunnerBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CriticalSection all_values_crit_;
|
RecursiveCriticalSection all_values_crit_;
|
||||||
Verifier verifier_;
|
Verifier verifier_;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -282,7 +282,7 @@ TEST(AtomicOpsTest, CompareAndSwap) {
|
|||||||
EXPECT_EQ(1, runner.shared_value());
|
EXPECT_EQ(1, runner.shared_value());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(CriticalSectionTest, Basic) {
|
TEST(RecursiveCriticalSectionTest, Basic) {
|
||||||
// Create and start lots of threads.
|
// Create and start lots of threads.
|
||||||
LockRunner<CriticalSectionLock> runner;
|
LockRunner<CriticalSectionLock> runner;
|
||||||
std::vector<std::unique_ptr<Thread>> threads;
|
std::vector<std::unique_ptr<Thread>> threads;
|
||||||
@ -320,7 +320,7 @@ class PerfTestData {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
uint8_t cache_line_barrier_1_[64];
|
uint8_t cache_line_barrier_1_[64];
|
||||||
CriticalSection lock_;
|
RecursiveCriticalSection lock_;
|
||||||
uint8_t cache_line_barrier_2_[64];
|
uint8_t cache_line_barrier_2_[64];
|
||||||
int64_t my_counter_ = 0;
|
int64_t my_counter_ = 0;
|
||||||
const int expected_count_;
|
const int expected_count_;
|
||||||
@ -372,7 +372,7 @@ class PerfTestThread {
|
|||||||
// user 1m20.575s
|
// user 1m20.575s
|
||||||
// sys 3m48.872s
|
// sys 3m48.872s
|
||||||
// Unit test output:
|
// Unit test output:
|
||||||
// [ OK ] CriticalSectionTest.Performance (294375 ms)
|
// [ OK ] RecursiveCriticalSectionTest.Performance (294375 ms)
|
||||||
//
|
//
|
||||||
// Native mutex implementation using first fit policy (current macOS default):
|
// Native mutex implementation using first fit policy (current macOS default):
|
||||||
// Approximate CPU usage:
|
// Approximate CPU usage:
|
||||||
@ -380,7 +380,7 @@ class PerfTestThread {
|
|||||||
// user 0m12.738s
|
// user 0m12.738s
|
||||||
// sys 0m31.207s
|
// sys 0m31.207s
|
||||||
// Unit test output:
|
// Unit test output:
|
||||||
// [ OK ] CriticalSectionTest.Performance (11444 ms)
|
// [ OK ] RecursiveCriticalSectionTest.Performance (11444 ms)
|
||||||
//
|
//
|
||||||
// Special partially spin lock based implementation:
|
// Special partially spin lock based implementation:
|
||||||
// Approximate CPU usage:
|
// Approximate CPU usage:
|
||||||
@ -388,10 +388,10 @@ class PerfTestThread {
|
|||||||
// user 0m3.014s
|
// user 0m3.014s
|
||||||
// sys 0m4.495s
|
// sys 0m4.495s
|
||||||
// Unit test output:
|
// Unit test output:
|
||||||
// [ OK ] CriticalSectionTest.Performance (1885 ms)
|
// [ OK ] RecursiveCriticalSectionTest.Performance (1885 ms)
|
||||||
//
|
//
|
||||||
// The test is disabled by default to avoid unecessarily loading the bots.
|
// The test is disabled by default to avoid unecessarily loading the bots.
|
||||||
TEST(CriticalSectionTest, DISABLED_Performance) {
|
TEST(RecursiveCriticalSectionTest, DISABLED_Performance) {
|
||||||
PerfTestThread threads[8];
|
PerfTestThread threads[8];
|
||||||
Event event;
|
Event event;
|
||||||
|
|
||||||
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
#include "rtc_base/checks.h"
|
#include "rtc_base/checks.h"
|
||||||
#include "rtc_base/constructor_magic.h"
|
#include "rtc_base/constructor_magic.h"
|
||||||
#include "rtc_base/critical_section.h"
|
#include "rtc_base/deprecated/recursive_critical_section.h"
|
||||||
#include "rtc_base/deprecation.h"
|
#include "rtc_base/deprecation.h"
|
||||||
#include "rtc_base/message_handler.h"
|
#include "rtc_base/message_handler.h"
|
||||||
#include "rtc_base/third_party/sigslot/sigslot.h"
|
#include "rtc_base/third_party/sigslot/sigslot.h"
|
||||||
@ -149,7 +149,7 @@ class DEPRECATED_SignalThread : public sigslot::has_slots<>,
|
|||||||
|
|
||||||
Thread* main_;
|
Thread* main_;
|
||||||
Worker worker_;
|
Worker worker_;
|
||||||
CriticalSection cs_;
|
RecursiveCriticalSection cs_;
|
||||||
State state_ RTC_GUARDED_BY(cs_);
|
State state_ RTC_GUARDED_BY(cs_);
|
||||||
int refcount_ RTC_GUARDED_BY(cs_);
|
int refcount_ RTC_GUARDED_BY(cs_);
|
||||||
bool destroy_called_ RTC_GUARDED_BY(cs_) = false;
|
bool destroy_called_ RTC_GUARDED_BY(cs_) = false;
|
||||||
|
|||||||
@ -955,7 +955,7 @@ class EventDispatcher : public Dispatcher {
|
|||||||
PhysicalSocketServer* ss_;
|
PhysicalSocketServer* ss_;
|
||||||
int afd_[2];
|
int afd_[2];
|
||||||
bool fSignaled_;
|
bool fSignaled_;
|
||||||
CriticalSection crit_;
|
RecursiveCriticalSection crit_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // WEBRTC_POSIX
|
#endif // WEBRTC_POSIX
|
||||||
|
|||||||
@ -21,7 +21,7 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "rtc_base/critical_section.h"
|
#include "rtc_base/deprecated/recursive_critical_section.h"
|
||||||
#include "rtc_base/net_helpers.h"
|
#include "rtc_base/net_helpers.h"
|
||||||
#include "rtc_base/socket_server.h"
|
#include "rtc_base/socket_server.h"
|
||||||
#include "rtc_base/system/rtc_export.h"
|
#include "rtc_base/system/rtc_export.h"
|
||||||
@ -111,7 +111,7 @@ class RTC_EXPORT PhysicalSocketServer : public SocketServer {
|
|||||||
DispatcherSet pending_remove_dispatchers_ RTC_GUARDED_BY(crit_);
|
DispatcherSet pending_remove_dispatchers_ RTC_GUARDED_BY(crit_);
|
||||||
bool processing_dispatchers_ RTC_GUARDED_BY(crit_) = false;
|
bool processing_dispatchers_ RTC_GUARDED_BY(crit_) = false;
|
||||||
Signaler* signal_wakeup_; // Assigned in constructor only
|
Signaler* signal_wakeup_; // Assigned in constructor only
|
||||||
CriticalSection crit_;
|
RecursiveCriticalSection crit_;
|
||||||
#if defined(WEBRTC_WIN)
|
#if defined(WEBRTC_WIN)
|
||||||
const WSAEVENT socket_ev_;
|
const WSAEVENT socket_ev_;
|
||||||
#endif
|
#endif
|
||||||
@ -191,7 +191,7 @@ class PhysicalSocket : public AsyncSocket, public sigslot::has_slots<> {
|
|||||||
SOCKET s_;
|
SOCKET s_;
|
||||||
bool udp_;
|
bool udp_;
|
||||||
int family_ = 0;
|
int family_ = 0;
|
||||||
CriticalSection crit_;
|
RecursiveCriticalSection crit_;
|
||||||
int error_ RTC_GUARDED_BY(crit_);
|
int error_ RTC_GUARDED_BY(crit_);
|
||||||
ConnState state_;
|
ConnState state_;
|
||||||
AsyncResolver* resolver_;
|
AsyncResolver* resolver_;
|
||||||
|
|||||||
@ -31,7 +31,7 @@
|
|||||||
#include "absl/algorithm/container.h"
|
#include "absl/algorithm/container.h"
|
||||||
#include "rtc_base/atomic_ops.h"
|
#include "rtc_base/atomic_ops.h"
|
||||||
#include "rtc_base/checks.h"
|
#include "rtc_base/checks.h"
|
||||||
#include "rtc_base/critical_section.h"
|
#include "rtc_base/deprecated/recursive_critical_section.h"
|
||||||
#include "rtc_base/logging.h"
|
#include "rtc_base/logging.h"
|
||||||
#include "rtc_base/null_socket_server.h"
|
#include "rtc_base/null_socket_server.h"
|
||||||
#include "rtc_base/synchronization/sequence_checker.h"
|
#include "rtc_base/synchronization/sequence_checker.h"
|
||||||
@ -88,8 +88,8 @@ class MessageHandlerWithTask final : public MessageHandler {
|
|||||||
|
|
||||||
class RTC_SCOPED_LOCKABLE MarkProcessingCritScope {
|
class RTC_SCOPED_LOCKABLE MarkProcessingCritScope {
|
||||||
public:
|
public:
|
||||||
MarkProcessingCritScope(const CriticalSection* cs, size_t* processing)
|
MarkProcessingCritScope(const RecursiveCriticalSection* cs,
|
||||||
RTC_EXCLUSIVE_LOCK_FUNCTION(cs)
|
size_t* processing) RTC_EXCLUSIVE_LOCK_FUNCTION(cs)
|
||||||
: cs_(cs), processing_(processing) {
|
: cs_(cs), processing_(processing) {
|
||||||
cs_->Enter();
|
cs_->Enter();
|
||||||
*processing_ += 1;
|
*processing_ += 1;
|
||||||
@ -101,7 +101,7 @@ class RTC_SCOPED_LOCKABLE MarkProcessingCritScope {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const CriticalSection* const cs_;
|
const RecursiveCriticalSection* const cs_;
|
||||||
size_t* processing_;
|
size_t* processing_;
|
||||||
|
|
||||||
RTC_DISALLOW_COPY_AND_ASSIGN(MarkProcessingCritScope);
|
RTC_DISALLOW_COPY_AND_ASSIGN(MarkProcessingCritScope);
|
||||||
|
|||||||
@ -29,7 +29,7 @@
|
|||||||
#include "api/task_queue/queued_task.h"
|
#include "api/task_queue/queued_task.h"
|
||||||
#include "api/task_queue/task_queue_base.h"
|
#include "api/task_queue/task_queue_base.h"
|
||||||
#include "rtc_base/constructor_magic.h"
|
#include "rtc_base/constructor_magic.h"
|
||||||
#include "rtc_base/critical_section.h"
|
#include "rtc_base/deprecated/recursive_critical_section.h"
|
||||||
#include "rtc_base/location.h"
|
#include "rtc_base/location.h"
|
||||||
#include "rtc_base/message_handler.h"
|
#include "rtc_base/message_handler.h"
|
||||||
#include "rtc_base/platform_thread_types.h"
|
#include "rtc_base/platform_thread_types.h"
|
||||||
@ -140,7 +140,7 @@ class RTC_EXPORT ThreadManager {
|
|||||||
// Methods that don't modify the list of message queues may be called in a
|
// Methods that don't modify the list of message queues may be called in a
|
||||||
// re-entrant fashion. "processing_" keeps track of the depth of re-entrant
|
// re-entrant fashion. "processing_" keeps track of the depth of re-entrant
|
||||||
// calls.
|
// calls.
|
||||||
CriticalSection crit_;
|
RecursiveCriticalSection crit_;
|
||||||
size_t processing_ RTC_GUARDED_BY(crit_) = 0;
|
size_t processing_ RTC_GUARDED_BY(crit_) = 0;
|
||||||
#if RTC_DCHECK_IS_ON
|
#if RTC_DCHECK_IS_ON
|
||||||
// Represents all thread seand actions by storing all send targets per thread.
|
// Represents all thread seand actions by storing all send targets per thread.
|
||||||
@ -531,7 +531,7 @@ class RTC_LOCKABLE RTC_EXPORT Thread : public webrtc::TaskQueueBase {
|
|||||||
|
|
||||||
friend class ScopedDisallowBlockingCalls;
|
friend class ScopedDisallowBlockingCalls;
|
||||||
|
|
||||||
CriticalSection* CritForTest() { return &crit_; }
|
RecursiveCriticalSection* CritForTest() { return &crit_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class QueuedTaskHandler final : public MessageHandler {
|
class QueuedTaskHandler final : public MessageHandler {
|
||||||
@ -582,7 +582,7 @@ class RTC_LOCKABLE RTC_EXPORT Thread : public webrtc::TaskQueueBase {
|
|||||||
std::vector<Thread*> allowed_threads_ RTC_GUARDED_BY(this);
|
std::vector<Thread*> allowed_threads_ RTC_GUARDED_BY(this);
|
||||||
bool invoke_policy_enabled_ RTC_GUARDED_BY(this) = false;
|
bool invoke_policy_enabled_ RTC_GUARDED_BY(this) = false;
|
||||||
#endif
|
#endif
|
||||||
CriticalSection crit_;
|
RecursiveCriticalSection crit_;
|
||||||
bool fInitialized_;
|
bool fInitialized_;
|
||||||
bool fDestroyed_;
|
bool fDestroyed_;
|
||||||
|
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#include "absl/algorithm/container.h"
|
#include "absl/algorithm/container.h"
|
||||||
#include "rtc_base/checks.h"
|
#include "rtc_base/checks.h"
|
||||||
#include "rtc_base/critical_section.h"
|
#include "rtc_base/deprecated/recursive_critical_section.h"
|
||||||
#include "rtc_base/fake_clock.h"
|
#include "rtc_base/fake_clock.h"
|
||||||
#include "rtc_base/logging.h"
|
#include "rtc_base/logging.h"
|
||||||
#include "rtc_base/physical_socket_server.h"
|
#include "rtc_base/physical_socket_server.h"
|
||||||
|
|||||||
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
#include "rtc_base/checks.h"
|
#include "rtc_base/checks.h"
|
||||||
#include "rtc_base/constructor_magic.h"
|
#include "rtc_base/constructor_magic.h"
|
||||||
#include "rtc_base/critical_section.h"
|
#include "rtc_base/deprecated/recursive_critical_section.h"
|
||||||
#include "rtc_base/event.h"
|
#include "rtc_base/event.h"
|
||||||
#include "rtc_base/fake_clock.h"
|
#include "rtc_base/fake_clock.h"
|
||||||
#include "rtc_base/message_handler.h"
|
#include "rtc_base/message_handler.h"
|
||||||
@ -295,7 +295,7 @@ class VirtualSocketServer : public SocketServer, public sigslot::has_slots<> {
|
|||||||
std::map<rtc::IPAddress, rtc::IPAddress> alternative_address_mapping_;
|
std::map<rtc::IPAddress, rtc::IPAddress> alternative_address_mapping_;
|
||||||
std::unique_ptr<Function> delay_dist_;
|
std::unique_ptr<Function> delay_dist_;
|
||||||
|
|
||||||
CriticalSection delay_crit_;
|
RecursiveCriticalSection delay_crit_;
|
||||||
|
|
||||||
double drop_prob_;
|
double drop_prob_;
|
||||||
bool sending_blocked_ = false;
|
bool sending_blocked_ = false;
|
||||||
@ -380,7 +380,7 @@ class VirtualSocket : public AsyncSocket,
|
|||||||
bool ready_to_send_ = true;
|
bool ready_to_send_ = true;
|
||||||
|
|
||||||
// Critical section to protect the recv_buffer and queue_
|
// Critical section to protect the recv_buffer and queue_
|
||||||
CriticalSection crit_;
|
RecursiveCriticalSection crit_;
|
||||||
|
|
||||||
// Network model that enforces bandwidth and capacity constraints
|
// Network model that enforces bandwidth and capacity constraints
|
||||||
NetworkQueue network_;
|
NetworkQueue network_;
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
#include "rtc_base/atomic_ops.h"
|
#include "rtc_base/atomic_ops.h"
|
||||||
#include "rtc_base/checks.h"
|
#include "rtc_base/checks.h"
|
||||||
#include "rtc_base/critical_section.h"
|
#include "rtc_base/deprecated/recursive_critical_section.h"
|
||||||
|
|
||||||
#import "RTCAudioSessionConfiguration.h"
|
#import "RTCAudioSessionConfiguration.h"
|
||||||
#import "base/RTCLogging.h"
|
#import "base/RTCLogging.h"
|
||||||
@ -35,7 +35,7 @@ NSString * const kRTCAudioSessionOutputVolumeSelector = @"outputVolume";
|
|||||||
// TODO(tkchin): Consider more granular locking. We're not expecting a lot of
|
// TODO(tkchin): Consider more granular locking. We're not expecting a lot of
|
||||||
// lock contention so coarse locks should be fine for now.
|
// lock contention so coarse locks should be fine for now.
|
||||||
@implementation RTC_OBJC_TYPE (RTCAudioSession) {
|
@implementation RTC_OBJC_TYPE (RTCAudioSession) {
|
||||||
rtc::CriticalSection _crit;
|
rtc::RecursiveCriticalSection _crit;
|
||||||
AVAudioSession *_session;
|
AVAudioSession *_session;
|
||||||
volatile int _activationCount;
|
volatile int _activationCount;
|
||||||
volatile int _lockRecursionCount;
|
volatile int _lockRecursionCount;
|
||||||
|
|||||||
@ -168,7 +168,7 @@ class EmulatedEndpointImpl : public EmulatedEndpoint {
|
|||||||
uint16_t NextPort() RTC_EXCLUSIVE_LOCKS_REQUIRED(receiver_lock_);
|
uint16_t NextPort() RTC_EXCLUSIVE_LOCKS_REQUIRED(receiver_lock_);
|
||||||
void UpdateReceiveStats(const EmulatedIpPacket& packet);
|
void UpdateReceiveStats(const EmulatedIpPacket& packet);
|
||||||
|
|
||||||
rtc::CriticalSection receiver_lock_;
|
rtc::RecursiveCriticalSection receiver_lock_;
|
||||||
rtc::ThreadChecker enabled_state_checker_;
|
rtc::ThreadChecker enabled_state_checker_;
|
||||||
|
|
||||||
uint64_t id_;
|
uint64_t id_;
|
||||||
|
|||||||
Reference in New Issue
Block a user