This prepares TaskQueueBase sub classes to be able to migrate to
the location and traits-based API. It re-introduces a Location class
into the webrtc namespace, which is meant to be overridden by Chromium.
Bug: chromium:1416199
Change-Id: I712c7806a71b3b99b2a2bf95e555b357c21c15ae
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/294381
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Markus Handell <handellm@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39400}
ThreadManager, i.e. list of all thread is only used for debugging
purpose now, such uses do not enter the loop recursively
Bug: webrtc:11567
Change-Id: I7deb86e0245950c92fe27485285fd119baf6707a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/289461
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38986}
With rtc::Thread::Clear removed, there are no longer calls to external code while holding the mutex and thus it doesn't need to be recursive.
Bug: webrtc:11567
Change-Id: If350684be0bfcbc33806019bd986138905aec66d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/276542
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38179}
BlockingCall doesn't take rtc::Location parameter and thus most of the dependencies on location can be removed
Bug: webrtc:11318
Change-Id: I91a17e342dd9a9e3e2c8f7fbe267474c98a8d0e5
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/274620
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38045}
To reduce usage of rtc::MessageHandler, hide rtc::Thread::Send into private section with intention to deprecate it in favor of the new Invoke function.
Bug: webrtc:9702, webrtc:11318
Change-Id: Ib4c26f9abc361e05a45b2a91929af58ab160b3f0
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/274166
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38036}
rtc::Thread::Dispose is only used in test code,
but complicates the main thread loop.
Bug: webrtc:8324
Change-Id: I2dccdadcdc932b9992958d1e70fb93d1879b7618
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/272821
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37894}
Remote Peek function as unused
Move Get and Dispatch into private section to ensure they are not used
from outside.
Bug: webrtc:9702
Change-Id: Ibd0b236fe43543d60f97f988524526493bbeaaa7
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/272804
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37889}
Lots of code call rtc::Thread directly instead of through TaskQueueBase
interface, thus to continue migration step by step rtc::Thread needs
to implement both old and new TaskQueueBase interfaces.
Bug: webrtc:14245
Change-Id: Ie7cac897a4c8a6227b8d467a39adb30aec6f1318
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/267984
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37474}
This is part of a large-scale effort to increase adoption of
absl::string_view across the WebRTC code base.
This CL converts the majority of "const std::string&"s in function
parameters under rtc_base/ to absl::string_view.
Bug: webrtc:13579
Change-Id: I2b1e3776aa42326aa405f76bb324a2d233b21dca
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/254081
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Xavier Lepaul <xalep@webrtc.org>
Reviewed-by: Anders Lilienthal <andersc@webrtc.org>
Reviewed-by: Per Kjellander <perkj@webrtc.org>
Commit-Queue: Ali Tofigh <alito@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36239}
rtc::Thread already contains PostTask/PostDelayedTask methods that are
inherited from webrtc::TaskQueueBase which are named the same thing and
do the same thing.
Bug: webrtc:13582
Change-Id: I23d897a0079496d89564a51cbb26d214b70e132a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/248168
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35881}
Because rtc::Thread inherits from TaskQueueBase, it already implements
a pair of PostTask/PostDelayedTask methods that we want to keep. But in
addition to those, rtc::Thread defines its own PostTask/PostDelayedTask
using templates. These are the versions that we want to deprecate.
They were originally implemented prior to rtc::Thread inheriting from
TaskQueueBase. We want to deprecate them because...
- We don't want to have multiple code paths that do the same thing.
- We want to move away from rtc::Thread to TaskQueueBase long-term.
- These versions are not overridable in Chromium.
- These versions don't have high/low precision versions of PDT.
Helper methods are added to rtc::Thread so that callers don't have to
wrap every lambda in webrtc::ToQueuedTask() and update dependencies.
Bug: webrtc:13582
Change-Id: I58702c53f4cb3705681bd9f1ea16b7aaa5052c18
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/247660
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Reviewed-by: Markus Handell <handellm@google.com>
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35750}
As per go/postdelayedtask-precision-in-webrtc we want to reduce the
precision of PostDelayedTask() in order to schedule work on the CPU
more efficiently. In order not to break "high precision" use cases, a
new API is added to allow opting in to high precision.
PostDelayedHighPrecisionTask() has the same precision that
PostDelayedTask() has today, but by changing the interface's
requirements on PostDelayedTask(), adding the high precision version
of it will unblock making the old PostDelayedTask() API lower
precision.
This CL does not update implementations to support low precision so
until those are updated, both PostDelayedTask() and
PostDelayedHighPrecisionTask() have the same precision (=high).
This CL also adds TODOs to make some rtc::Thread-specific versions
of PostTask/PostDelayedTask obsolete, see
https://crbug.com/webrtc/13582 for more info.
Bug: webrtc:13583, webrtc:13582
Change-Id: I4c6d53d22bb299c49893ce9f3ef73a40d8c75de1
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/247367
Reviewed-by: Markus Handell <handellm@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35748}
This is a reland of 9f2a20f434
See https://webrtc-review.googlesource.com/c/src/+/226563/1..2
for the fix. RTC_DCHECK_ALWAYS_ON needs to be in public_configs
in order to be propagated together with header #includes and
avoid ODR violations.
Original change's description:
> Add WebRTC specific dcheck_always_on.
>
> Inspired by V8 CL: crrev.com/c/3038528.
>
> This makes the WebRTC's dcheck control independent of Chromium's and
> prepares switching Chromium's default behavior without affecting
> WebRTC developers or builders.
>
> Preparation for: https://crrev.com/c/2893204
>
> Bug: chromium:1225701, webrtc:12988
> Change-Id: Ia0d21f9fb8e9d7704fd1beca16504c301a263b3b
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/226465
> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
> Reviewed-by: Markus Handell <handellm@webrtc.org>
> Reviewed-by: Dirk Pranke <dpranke@google.com>
> Cr-Commit-Position: refs/heads/master@{#34512}
Bug: chromium:1225701, webrtc:12988
Change-Id: I1f78587487ee7b1a4a07b8c91b737a9e797b2323
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/226563
Reviewed-by: Florent Castelli <orphis@webrtc.org>
Reviewed-by: Markus Handell <handellm@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34519}
Inspired by V8 CL: crrev.com/c/3038528.
This makes the WebRTC's dcheck control independent of Chromium's and
prepares switching Chromium's default behavior without affecting
WebRTC developers or builders.
Preparation for: https://crrev.com/c/2893204
Bug: chromium:1225701, webrtc:12988
Change-Id: Ia0d21f9fb8e9d7704fd1beca16504c301a263b3b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/226465
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Markus Handell <handellm@webrtc.org>
Reviewed-by: Dirk Pranke <dpranke@google.com>
Cr-Commit-Position: refs/heads/master@{#34512}
It was used only to break the circular dependency between SocketServer
and Thread at destruction time. Replaced with a method call to
SetMessageQueue(nullptr).
Bug: webrtc:11943
Change-Id: I0606d473ad79655cca28411bb02c21e21d2d7220
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/215587
Reviewed-by: Tommi <tommi@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33807}
Also removing a count check from DestroyTransceiverChannel that's
not useful right now. We can bring it back when we have
DestroyChannelInterface better under control as far as Invokes goes.
Bug: none
Change-Id: I8e9c55a980f8f20e8b996fdc461fd90b0fbd4f3d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/215201
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33730}
This is useful to understand how often we block in certain parts of the
api and track improvements/regressions.
There are two macros, both are only active for RTC_DCHECK_IS_ON builds:
* RTC_LOG_THREAD_BLOCK_COUNT()
Example:
void MyClass::MyFunction() {
RTC_LOG_THREAD_BLOCK_COUNT();
thread_->Invoke<void>([this](){ DoStuff(); });
}
When executing this function during a test, the output could be:
(my_file.cc:2): Blocking MyFunction: total=1 (actual=1, would=0)
The words 'actual' and 'would' reflect whether an actual thread switch
was made, or if in the case of a test using the same thread for more
than one role (e.g. signaling, worker, network are all the same thread)
that an actual thread switch did not occur but it would have occurred
in the case of having dedicated threads. The 'total' count is the sum.
* RTC_DCHECK_BLOCK_COUNT_NO_MORE_THAN(x)
Example:
void MyClass::MyFunction() {
RTC_LOG_THREAD_BLOCK_COUNT();
thread_->Invoke<void>([this](){ DoStuff(); });
thread_->Invoke<void>([this](){ MoreStuff(); });
RTC_DCHECK_BLOCK_COUNT_NO_MORE_THAN(1);
}
When a function is known to have blocking calls and we want to not
regress from the currently known number of blocking calls, we can use
this macro to state that at a certain point in a function, below
where RTC_LOG_THREAD_BLOCK_COUNT() is called, there must have occurred
no more than |x| (total) blocking calls. If more occur, a DCHECK will
hit and print out what the actual number of calls was:
# Fatal error in: my_file.cc, line 5
# last system error: 60
# Check failed: blocked_call_count_printer.GetTotalBlockedCallCount() <= 1 (2 vs. 1)
Bug: webrtc:12649
Change-Id: Ibac4f85f00b89680601dba54a651eac95a0f45d3
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/213782
Commit-Queue: Tommi <tommi@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33632}
As documented in webrtc:11908 this cleanup is fairly invasive and
when a part of a frequently executed code path, can be quite costly
in terms of performance overhead. This is currently the case with
synchronous calls between threads (Thread) as well with our proxy
api classes.
With this CL, all code in WebRTC should now either be using MessageHandlerAutoCleanup
or calling MessageHandler(false) explicitly.
Next steps will be to update external code to either depend on the
AutoCleanup variant, or call MessageHandler(false).
Changing the proxy classes to use TaskQueue set of concepts instead of
MessageHandler. This avoids the perf overhead related to the cleanup
above as well as incompatibility with the thread policy checks in
Thread that some current external users of the proxies would otherwise
run into (if we were to use Thread::Send() for synchronous call).
Following this we'll move the cleanup step into the AutoCleanup class
and an RTC_DCHECK that all calls to the MessageHandler are setting
the flag to false, before eventually removing the flag and make
MessageHandler pure virtual.
Bug: webrtc:11908
Change-Id: Idf4ff9bcc8438cb8c583777e282005e0bc511c8f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/183442
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Commit-Queue: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32049}
Send() was creating an instance of AutoThread for every call,
which is equivalent of instantiatiating a whole new instance of
Thread (AutoThread inherits from Thread) and not just ensuring that
a thread instance is registered for the current thread, as the
comments indicated.
Bug: webrtc:11908
Change-Id: I8bbb43ca83c30d9f5e1928205b3611271ecad053
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/183441
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32037}
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}
Policy will allow explicitly specify thread between which invokes are
allowed, or explicitly forbid any invokes.
Change-Id: I360e7cba3ce1c21abd5047c6f175d8c4e0e99c6f
Bug: webrtc:11728
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/177526
Reviewed-by: Tommi <tommi@webrtc.org>
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31604}
This reverts commit 28685dc08c.
Reason for revert: Speculative reland after looking into downstream
failures. It's possible that carryover state from unrelated tests
running in parallel was causing failures.
Original change's description:
> Revert "Make sure that "current" rtc::Thread instances are always current for TaskQueueBase."
>
> This reverts commit 46b3bc6c24.
>
> Reason for revert: Speculative revert. Breaks downstream project
>
> Original change's description:
> > Make sure that "current" rtc::Thread instances are always current for TaskQueueBase.
> >
> > This is a necessary part of fulfilling the TaskQueueBase
> > interface. If a thread does not register as the current TQ, yet offers
> > the TQ interface, TQ 'current' checks will not work as expected and
> > code that relies them (TaskQueueBase::Current() and IsCurrent())
> > will run in unexpected ways.
> >
> > Bug: webrtc:11572
> > Change-Id: Iab747bc474e74e6ce4f9e914cfd5b0578b19d19c
> > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/175080
> > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
> > Commit-Queue: Tommi <tommi@webrtc.org>
> > Cr-Commit-Position: refs/heads/master@{#31254}
>
> TBR=mbonadei@webrtc.org,tommi@webrtc.org
>
> Change-Id: I69ff3355f0ec447b25604bd95fdacbdb4d4f3f27
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: webrtc:11572
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/175104
> Reviewed-by: Artem Titov <titovartem@webrtc.org>
> Commit-Queue: Artem Titov <titovartem@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#31259}
TBR=mbonadei@webrtc.org,tommi@webrtc.org,titovartem@webrtc.org
# Not skipping CQ checks because this is a reland.
Bug: webrtc:11572
Change-Id: I00c82d99af8e05851769e09cb682b5b73895a6f3
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/175133
Reviewed-by: Tommi <tommi@webrtc.org>
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Commit-Queue: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31273}
This reverts commit 46b3bc6c24.
Reason for revert: Speculative revert. Breaks downstream project
Original change's description:
> Make sure that "current" rtc::Thread instances are always current for TaskQueueBase.
>
> This is a necessary part of fulfilling the TaskQueueBase
> interface. If a thread does not register as the current TQ, yet offers
> the TQ interface, TQ 'current' checks will not work as expected and
> code that relies them (TaskQueueBase::Current() and IsCurrent())
> will run in unexpected ways.
>
> Bug: webrtc:11572
> Change-Id: Iab747bc474e74e6ce4f9e914cfd5b0578b19d19c
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/175080
> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
> Commit-Queue: Tommi <tommi@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#31254}
TBR=mbonadei@webrtc.org,tommi@webrtc.org
Change-Id: I69ff3355f0ec447b25604bd95fdacbdb4d4f3f27
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:11572
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/175104
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31259}
This is a necessary part of fulfilling the TaskQueueBase
interface. If a thread does not register as the current TQ, yet offers
the TQ interface, TQ 'current' checks will not work as expected and
code that relies them (TaskQueueBase::Current() and IsCurrent())
will run in unexpected ways.
Bug: webrtc:11572
Change-Id: Iab747bc474e74e6ce4f9e914cfd5b0578b19d19c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/175080
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31254}
This makes it easier to maintain consistency between real time
and simulated time modes.
The RealTimeController is updated to use an explicit main thread,
this ensures that pending destruction tasks are run as the network
emulator goes out of scope.
Bug: webrtc:11255
Change-Id: Ie73ab778c78a68d7c58c0f857f14a8d8ac027c67
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/166164
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Steve Anton <steveanton@webrtc.org>
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30342}
This prepares for introducing a simulated time rtc::ThreadManager
implementation that will run on a single underlying thread.
Bug: webrtc:11255
Change-Id: I793128cc0b8e649a3675914de67dfee3298b446a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/165765
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Steve Anton <steveanton@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30256}