Commit graph

72 commits

Author SHA1 Message Date
Danil Chapovalov
7c323ad47c in rtc::Thread introduce Invoke without rtc::Location parameter
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}
2022-09-08 15:00:40 +00:00
Danil Chapovalov
1e6965a857 Remove usage of MessageHandlerAutoCleanup in rtc_base unittests
Bug: webrtc:11988
Change-Id: I95017df0cd188897a0507bb07e7e571343f80262
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/274161
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38008}
2022-09-05 10:14:50 +00:00
Danil Chapovalov
16242931e3 Delete DEPRECATED_AsyncInvoke
Bug: webrtc:12339
Change-Id: I5de095da811e117f7d3db499a3c9da5c29c08f4f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/273880
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37996}
2022-09-02 14:02:34 +00:00
Ali Tofigh
4b6819434d Reland "Add TaskQueueStdlib experiment."
This is a reland of commit 83db78e854

Original change's description:
> Add TaskQueueStdlib experiment.
>
> Bug: webrtc:14389
> Change-Id: I23c6e0ae675748ec35a99c334104dd2654995a33
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/265802
> Commit-Queue: Ali Tofigh <alito@webrtc.org>
> Reviewed-by: Harald Alvestrand <hta@webrtc.org>
> Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
> Reviewed-by: Jonas Oreland <jonaso@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#37888}

Bug: webrtc:14389
Change-Id: If84c7043e5f0f63ae8d9eae651daf900a72f2ee3
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/273320
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Ali Tofigh <alito@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37923}
2022-08-29 10:48:42 +00:00
Danil Chapovalov
71cf2d0eb1 Delete rtc::Thread::Dispose as unused
Bug: webrtc:8324
Change-Id: I18ed725bd95f133f4c43f1268eb37179053557da
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/273104
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Auto-Submit: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37918}
2022-08-26 14:44:09 +00:00
Ali Tofigh
e7e3d5925a Revert "Add TaskQueueStdlib experiment."
This reverts commit 83db78e854.

Reason for revert: Some tests in Chromium's blink no longer compile because of the change in the signature of the CreateDefaultTaskQueueFactory() function.

Original change's description:
> Add TaskQueueStdlib experiment.
>
> Bug: webrtc:14389
> Change-Id: I23c6e0ae675748ec35a99c334104dd2654995a33
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/265802
> Commit-Queue: Ali Tofigh <alito@webrtc.org>
> Reviewed-by: Harald Alvestrand <hta@webrtc.org>
> Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
> Reviewed-by: Jonas Oreland <jonaso@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#37888}

Bug: webrtc:14389
Change-Id: If3e63d6b4ab9e838dc5020b88076a73fd29916e4
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/272920
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Auto-Submit: Ali Tofigh <alito@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37902}
2022-08-25 12:41:05 +00:00
Danil Chapovalov
0bd166530d in rtc::Thread remove special handling of the Dispose message
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}
2022-08-24 18:58:17 +00:00
Danil Chapovalov
207f8536b2 In rtc::Thread hide MessageHandler handling as implementation details
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}
2022-08-24 13:40:09 +00:00
Ali Tofigh
83db78e854 Add TaskQueueStdlib experiment.
Bug: webrtc:14389
Change-Id: I23c6e0ae675748ec35a99c334104dd2654995a33
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/265802
Commit-Queue: Ali Tofigh <alito@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Reviewed-by: Jonas Oreland <jonaso@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37888}
2022-08-24 11:28:39 +00:00
Markus Handell
2cfc1af78a Update rtc::Event::Wait call sites to use TimeDelta.
Bug: webrtc:14366
Change-Id: I949c1d26f030696b18153afef977633c9a5bd4cf
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/272003
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Markus Handell <handellm@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37835}
2022-08-19 10:07:28 +00:00
Danil Chapovalov
4bcf809df7 In rtc::Thread implement posting AnyInvocable
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}
2022-07-07 07:40:14 +00:00
Niels Möller
7a66900683 Delete rtc_base/atomic_ops.h
Bug: webrtc:9305
Change-Id: I3e8b0db03b84b5361d63db31ee23e6db3deabfe4
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/266497
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37348}
2022-06-28 08:32:13 +00:00
Artem Titov
c374d11fac Move to_queued_task.h and pending_task_safety_flag.h into public API
Bug: b/235812579
Change-Id: I9fa3dc4a65044df8b44fff4e9bfeac7233fa381c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/266080
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37248}
2022-06-17 09:20:39 +00:00
Niels Möller
83830f316e Delete TestListener and top-level thread wrapping.
Instead use rtc::AutoThread in tests that need that.

Bug: webrtc:9714
Change-Id: I1f33b1b2d321770d062504dd9ef86d66a345dd42
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/254681
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36950}
2022-05-20 15:21:21 +00:00
Henrik Boström
595f688b56 Delete legacy rtc::Thread PostTask APIs.
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}
2022-02-02 08:32:31 +00:00
Henrik Boström
2deee4bbb2 Mark rtc::Thread's versions of PostTask/PostDelayedTask deprecated.
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}
2022-01-20 12:59:27 +00:00
Byoungchan Lee
14af7622a7 Remove RTC_DISALLOW_COPY_AND_ASSIGN from rtc_base/
Bug: webrtc:13555, webrtc:13082
Change-Id: I406b7f04497562866ea3329e97c5adc96e927b6f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/245680
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Commit-Queue: (Daniel.L) Byoungchan Lee <daniel.l@hpcnt.com>
Cr-Commit-Position: refs/heads/main@{#35691}
2022-01-13 20:42:15 +00:00
Tommi
0a7a8e0aba Remove DEPRECATED_AsyncInvoker::Flush.
The method is not used so can be safely deleted before the full
(and eventual) removal of the implementation.

Bug: webrtc:12339
Change-Id: I7726313c46562041f670c3baec2db955de0b4298
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/238141
Auto-Submit: Tommi <tommi@webrtc.org>
Commit-Queue: Tommi <tommi@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35375}
2021-11-18 09:08:55 +00:00
Tommi
9ebe6d7c88 Remove the AsyncInvoker alias.
This emphasizes the "hint" to potential external users that the
class has been deprecated.

Bug: webrtc:12339
Change-Id: Iab83481af69a505059297cce959f02b5ab649f2f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/237805
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35368}
2021-11-17 13:37:06 +00:00
Niels Möller
d0b8879770 Delete AsyncSocket class, merge into Socket class
Bug: webrtc:13065
Change-Id: I13afee2386ea9c4de0e4fa95133f0c4d3ec826e8
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/227031
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34787}
2021-08-17 15:39:25 +00:00
Mirko Bonadei
481e3451d1 Revert rtc_dcheck_always_on.
This CL reverts:
https://webrtc-review.googlesource.com/c/src/+/226864
https://webrtc-review.googlesource.com/c/src/+/226563

Reason for revert:
See also V8 equivalent: crrev.com/c/3055294.
This has been properly fixed by crrev.com/c/3053740.
Now dcheck_always_on already defaults to false for subprojects
like WebRTC and no other switch is required. The switch didn't fully
work anyways due to https://crbug.com/1231890.

No-Try: True
Bug: chromium:1225701, webrtc:12988
Change-Id: I9888d7ac02ef2ba4fdc372de20f1d2d71f6d0299
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/227021
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Andrey Logvin <landrey@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34603}
2021-07-30 13:47:50 +00:00
Mirko Bonadei
386b5c3f4e Switch from GTEST_FLAG to GTEST_FLAG_SET.
::testing::GTEST_FLAG is deprecated and it will be removed in future
versions of gtest.

Bug: None
Change-Id: Icb2ad2a7607073cf9ad63753a4de34f37bda411c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/227083
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34600}
2021-07-30 12:08:38 +00:00
Artem Titov
96e3b991da Use backticks not vertical bars to denote variables in comments for /rtc_base
Bug: webrtc:12338
Change-Id: I72fcb505a92f03b2ace7160ee33d555a977eddfd
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/226955
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34587}
2021-07-28 13:51:47 +00:00
Mirko Bonadei
8c185fcabe Reland "Add WebRTC specific dcheck_always_on."
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}
2021-07-21 13:26:14 +00:00
Mirko Bonadei
145f289552 Revert "Add WebRTC specific dcheck_always_on."
This reverts commit 9f2a20f434.

Reason for revert: see explanation on 
https://bugs.chromium.org/p/webrtc/issues/detail?id=12988#c4.

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}

TBR=mbonadei@webrtc.org,dpranke@google.com,orphis@webrtc.org,handellm@webrtc.org,webrtc-scoped@luci-project-accounts.iam.gserviceaccount.com

Change-Id: I408ca6222e0d16e3d521708dfe5322236cf280d4
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: chromium:1225701, webrtc:12988
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/226562
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34518}
2021-07-21 07:54:10 +00:00
Mirko Bonadei
9f2a20f434 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}
2021-07-20 09:13:58 +00:00
Niels Möller
0694ce7d1b Mark AsyncInvoker as deprecated
Also fix similar annotation on NackModule to have effect
(when defining an alias with C++ using, ABSL_DEPRECATED should appear
on the left hand side).

Bug: webrtc:12339
Change-Id: Id80a20bf2c56a826777b8a40e06ac5c65e4f8db7
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/217242
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33905}
2021-05-03 16:27:10 +00:00
Niels Möller
9bd2457857 Delete SignalQueueDestroyed
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}
2021-04-22 13:04:53 +00:00
Tomas Gunnarsson
89f3dd5bf7 Make RTC_LOG_THREAD_BLOCK_COUNT less spammy for known call counts
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}
2021-04-14 12:19:12 +00:00
Tommi
fe041643b4 Add utility to count the number of blocking thread invokes.
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}
2021-04-07 10:02:41 +00:00
Niels Möller
1a29a5da84 Delete rtc::Bind
Bug: webrtc:11339
Change-Id: Id53d17bbf37a15f482e9eb9f8762d2000c772dcc
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/202250
Reviewed-by: Tommi <tommi@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33099}
2021-01-29 08:24:43 +00:00
Mirko Bonadei
e5f4c6b8d2 Reland "Refactor rtc_base build targets."
This is a reland of 69241a93fb

Fix: The problem was related to NO_MAIN_THREAD_WRAPPING, which
affects https://source.chromium.org/chromium/chromium/src/+/master:third_party/webrtc/rtc_base/thread.cc;l=257-263;drc=7acc2d9fe3a6e3c4d8881d2bdfc9b8968a724cd5.
The original CL didn't attach the definition of the macro
NO_MAIN_THREAD_WRAPPING when building for Chromium (which doesn't have
to be related to //rtc_base anymore but to //rtc_base:threading).

Original change's description:
> Refactor rtc_base build targets.
>
> The "//rtc_base:rtc_base" build target has historically been one of the
> biggest targets in the WebRTC build. Big targets are the main source of
> circular dependencies and non-API types leakage.
>
> This CL is a step forward into splitting "//rtc_base:rtc_base" into
> smaller targets (as originally started in 2018).
>
> The only non-automated changes are (like re-wiring the build system):
> * The creation of //rtc_base/async_resolver.{h,cc} which allows to
>   break a circular dependency (is has been extracted from
>   //rtc_base/net_helpers.{h,cc}).
> * The creation of //rtc_base/internal/default_socket_server.{h,cc} to
>   break another circular dependency.
>
> Bug: webrtc:9987
> Change-Id: I0c8f5e7efe2c8fd8e6bffa0d6dd2dd494cf3df02
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/196903
> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
> Reviewed-by: Harald Alvestrand <hta@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#32941}

Bug: webrtc:9987
Change-Id: I7cdf49d2aac8357f1f50f90010bf2c2f62fa19f6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/202021
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33001}
2021-01-15 17:00:05 +00:00
Mirko Bonadei
7acc2d9fe3 Revert "Refactor rtc_base build targets."
This reverts commit 69241a93fb.

Reason for revert: Breaks WebRTC roll into Chromium.

Original change's description:
> Refactor rtc_base build targets.
>
> The "//rtc_base:rtc_base" build target has historically been one of the
> biggest targets in the WebRTC build. Big targets are the main source of
> circular dependencies and non-API types leakage.
>
> This CL is a step forward into splitting "//rtc_base:rtc_base" into
> smaller targets (as originally started in 2018).
>
> The only non-automated changes are (like re-wiring the build system):
> * The creation of //rtc_base/async_resolver.{h,cc} which allows to
>   break a circular dependency (is has been extracted from
>   //rtc_base/net_helpers.{h,cc}).
> * The creation of //rtc_base/internal/default_socket_server.{h,cc} to
>   break another circular dependency.
>
> Bug: webrtc:9987
> Change-Id: I0c8f5e7efe2c8fd8e6bffa0d6dd2dd494cf3df02
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/196903
> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
> Reviewed-by: Harald Alvestrand <hta@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#32941}

TBR=mbonadei@webrtc.org,hta@webrtc.org

# Not skipping CQ checks because original CL landed > 1 day ago.

No-Try: True
Bug: webrtc:9987
Change-Id: I1e36ad64cc60092f38d6886153a94f1a58339256
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/201840
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Markus Handell <handellm@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32986}
2021-01-14 21:27:38 +00:00
Mirko Bonadei
69241a93fb Refactor rtc_base build targets.
The "//rtc_base:rtc_base" build target has historically been one of the
biggest targets in the WebRTC build. Big targets are the main source of
circular dependencies and non-API types leakage.

This CL is a step forward into splitting "//rtc_base:rtc_base" into
smaller targets (as originally started in 2018).

The only non-automated changes are (like re-wiring the build system):
* The creation of //rtc_base/async_resolver.{h,cc} which allows to
  break a circular dependency (is has been extracted from
  //rtc_base/net_helpers.{h,cc}).
* The creation of //rtc_base/internal/default_socket_server.{h,cc} to
  break another circular dependency.

Bug: webrtc:9987
Change-Id: I0c8f5e7efe2c8fd8e6bffa0d6dd2dd494cf3df02
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/196903
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32941}
2021-01-11 18:32:30 +00:00
Tomas Gunnarsson
abdb470d00 Make MessageHandler cleanup optional.
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}
2020-09-07 12:57:15 +00:00
Markus Handell
4ab7ddeb9f Migrate stray leftovers from rtc_base/ and test/ to webrtc::Mutex.
Migrates cases found from manual inspection of the code.

Bug: webrtc:11567
Change-Id: Ie8866435f3d3ca325e0811bf7cfb7e388ec987d4
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/179067
Reviewed-by: Tommi <tommi@webrtc.org>
Commit-Queue: Markus Handell <handellm@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31717}
2020-07-13 13:14:34 +00:00
Tomas Gunnarsson
b504780c42 Remove unused GuardedAsyncInvoker class
Bug: none
Change-Id: I0d05964c9be8a692f1589b4cebc84ee48c91be20
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/178864
Reviewed-by: Markus Handell <handellm@webrtc.org>
Commit-Queue: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31669}
2020-07-08 10:46:20 +00:00
Artem Titov
dfc5f0d19d Reland "Add rtc::Thread invoke policy."
This is a reland of 26d4f9cd39

Original change's description:
> Add rtc::Thread invoke policy.
> 
> 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}

Bug: webrtc:11728
Change-Id: Id700b870d8c8dd6fa97380422e568dfb69de131f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/178564
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Reviewed-by: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31621}
2020-07-03 11:33:17 +00:00
Artem Titov
f37e9a385e Revert "Add rtc::Thread invoke policy."
This reverts commit 26d4f9cd39.

Reason for revert: Breaks downstream project

Original change's description:
> Add rtc::Thread invoke policy.
> 
> 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}

TBR=tommi@webrtc.org,titovartem@webrtc.org

Change-Id: If49596831d532ed97ac80416a2358c0fc4567758
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:11728
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/178561
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31611}
2020-07-02 10:17:13 +00:00
Artem Titov
26d4f9cd39 Add rtc::Thread invoke policy.
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}
2020-07-01 12:01:32 +00:00
Tommi
6866dc7806 Reland "Make sure that "current" rtc::Thread instances are always current for TaskQueueBase."
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}
2020-05-15 10:20:03 +00:00
Artem Titov
28685dc08c 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}
2020-05-14 13:55:22 +00:00
Tommi
46b3bc6c24 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}
2020-05-14 12:40:42 +00:00
Mirko Bonadei
f7f6870f1b Mark static const class/struct members as constexpr.
This change fixes declarations that have initial values but are
technically not definitions by marking them constexpr (which counts as a
definition).

Bug: None
Change-Id: Icbecf8d83faffa83b9f7e1ffe4d6ef3a3f0b0c2a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/173587
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31073}
2020-04-15 09:30:07 +00:00
Sebastian Jansson
da7267a10f Makes Thread::Send execute sent messages after pending posted messages.
Bug: webrtc:11255
Change-Id: I4b9036d22c9db3a5ec0e19fc5f2f5ac0d7e2289a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/168058
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Ali Tofigh <alito@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30667}
2020-03-03 12:15:55 +00:00
Danil Chapovalov
0c626afcf3 Use newer version of TimeDelta and TimeStamp factories in webrtc
find . -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::Micros<\(.*\)>()/TimeDelta::Micros(\1)/g"
find . -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::Millis<\(.*\)>()/TimeDelta::Millis(\1)/g"
find . -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::Seconds<\(.*\)>()/TimeDelta::Seconds(\1)/g"
find . -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::us/TimeDelta::Micros/g"
find . -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::ms/TimeDelta::Millis/g"
find . -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/TimeDelta::seconds/TimeDelta::Seconds/g"
find . -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::Micros<\(.*\)>()/Timestamp::Micros(\1)/g"
find . -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::Millis<\(.*\)>()/Timestamp::Millis(\1)/g"
find . -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::Seconds<\(.*\)>()/Timestamp::Seconds(\1)/g"
find . -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::us/Timestamp::Micros/g"
find . -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::ms/Timestamp::Millis/g"
find . -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/Timestamp::seconds/Timestamp::Seconds/g"
git cl format

Bug: None
Change-Id: I87469d2e4a38369654da839ab7c838215a7911e7
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/168402
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30491}
2020-02-10 12:21:17 +00:00
Sebastian Jansson
73387823a7 Cleanup: Removes MessageQueue header and alias
Bug: webrtc:9883
Change-Id: I31aac563e54d61f03ff76ea1e9d284602a633252
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/166170
Reviewed-by: Steve Anton <steveanton@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30314}
2020-01-20 09:47:26 +00:00
Steve Anton
094396fb76 Use a fake clock for rtc::Thread::PostDelayedTask test
The test would flake using a real clock since time may pass between
calls to PostDelayedTask which would result in the tasks running
out of the expected order.

Bug: webrtc:11208, webrtc:11219
Change-Id: Ice5fe6ec4e9bf2ce89f00c6de7ed06b89dbe88cc
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/162100
Reviewed-by: Yves Gerey <yvesg@google.com>
Commit-Queue: Steve Anton <steveanton@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30101}
2019-12-16 15:46:48 +00:00
Steve Anton
bcc1a765fb Add rtc::Thread::PostDelayedTask
Earlier, rtc::Thread::PostTask was added as a convenient
alternative to MessageHandlers. This CL additionally adds support
for posting delayed tasks in a similar manner.

Bug: webrtc:10294
Change-Id: I0957b59ca2133a882c980bd2ad109fa03d701a16
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/161740
Commit-Queue: Steve Anton <steveanton@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30069}
2019-12-11 20:42:43 +00:00
Danil Chapovalov
912b3b83b3 Make rtc::Thread a TaskQueue
in support of converging on single way to run asynchronous tasks in webrtc

Bug: b/144982320
Change-Id: I200ad298136d11764a3f5c0547ebcba51aceafa0
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/158782
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29896}
2019-11-25 11:38:27 +00:00