Commit graph

19 commits

Author SHA1 Message Date
Markus Handell
fb727f3a5f Implement support for Chrome task origin tracing. #3.9/4
This CL forwards repeating task client locations to the passed
task queue.

Bug: chromium:1416199
Change-Id: I437d596f8d327d13498b47dfc0a03812af870331
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/295623
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Markus Handell <handellm@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39443}
2023-03-01 15:47:54 +00:00
Danil Chapovalov
4b97928b30 Refactor RepeatingTaskHandle to use absl::AnyInvocable
Allow to use AnyInvocable in webrtc.
Demonstrate how AnyInvocable can make interface clearer to read and implement
Demonstrate that AnyInvocable can reduce binary size

Bug: None
Change-Id: I33cf33fac6ed3bf4c5e46077d1cd984ca0f253a3
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/267165
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37380}
2022-06-30 12:22:17 +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
Peter Kasting
662d7f11d5 Fixes to support building in -std=c++20 mode.
* Structs with user-declared constructors are no longer considered
  aggregates, so remove the declarations when possible
* Types of both arguments to "==" must match to avoid "ambiguous
  function call" warning
* Various types of math involving enums are deprecated, so replace with
  constexprs where necessary
* ABSL_CONST_INIT must be used on definition as well as declaration
* volatile memory may no longer be read from and written to by the same
  operator, so replace e.g. "n++" with "n = n + 1"
* Replace an outdated check for no_unique_address support with
  __has_cpp_attribute
* std::result_of(f(x)) has been removed, replace with
  std::invoke_result(f, x)

Bug: chromium:1284275
Change-Id: I77b366ab1da7eb2c1e4c825b2714417c31ee5903
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/261221
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Reviewed-by: Tomas Gunnarsson <tommi@google.com>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36786}
2022-05-05 17:15:58 +00:00
Henrik Boström
27e8a095bf Add ability to specify delayed task precision in RepeatingTaskHandle.
See go/postdelayedtask-precision-in-webrtc for context of which use
cases are considered "high" or "low". Most use cases are "low" which
is the default, but this CL allows opting in to "high".

Will be used by FrameBuffer2.

Bug: webrtc:13604
Change-Id: Iebf6eea44779873e78746da749a39e1101b92819
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/248861
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35776}
2022-01-24 17:56:50 +00:00
Niels Möller
902b55457a Let a RepeatingTask stop itself by returning a delay of PlusInfinity.
Bug: none
Change-Id: I5bf87e236019d156ffe85c5b91ce09f5f4042937
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/247160
Reviewed-by: Evan Shrubsole <eshr@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35710}
2022-01-17 14:57:02 +00:00
Markus Handell
c1c6bef99a RepeatingTask: equip with DTrace probes.
This change permits dtrace wakeup profiling of Chromium production
builds.

Bug: webrtc:13013
Change-Id: Iff936f7ff03ba7ef349f2bc7d3826a7c8b1bb1b8
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/226461
Commit-Queue: Markus Handell <handellm@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34541}
2021-07-23 10:36:04 +00:00
Danil Chapovalov
0f9a8e33c0 Make stopping of the RepeatingTask safer
Previous implementation assumes that though RepeatingTask is owned by
the task queue, it will stay alive until RepeatingTaskHandler stops it.
That assumption doesn't hold by one of downstream TaskQueue implementaions.
That TaskQueue implementation shortly before destruction deletes
pending delayed tasks because it doesn't plan to run them,
and then runs remaining regular tasks.

Bug: None
Change-Id: Ic95fec2e9961b3f05727ff6fbdaf0664434a995b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/221984
Reviewed-by: Tommi <tommi@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34274}
2021-06-11 21:54:54 +00:00
Tommi
532cac526c Add support for injecting Clock to RepeatingTaskHandle.
This will improve support for tests that use Clock as well as offer
a way to remove use of Sleep() in the tests.

Bug: none
Change-Id: I25fd0c6fc1b52ec0c917e56fae6807b136213d8d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/175566
Commit-Queue: Tommi <tommi@webrtc.org>
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31305}
2020-05-18 14:11:44 +00:00
Tommi
29a5fe8a4f Reland "Revert back to using the task_queue_ for guarding access."
This reverts commit af1b9ceb62.

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 "Revert back to using the task_queue_ for guarding access."
> 
> This reverts commit 475006d4a3.
> 
> Reason for revert: Speculative revert. Breaks downstream project
> 
> Original change's description:
> > Revert back to using the task_queue_ for guarding access.
> > 
> > This removes the SequenceChecker that was temporarily used while
> > the rtc::Thread TQ implementation was being fixed.
> > 
> > Bug: none
> > Change-Id: Iaa46e47371211ac0a97b2dcaf23cef12b43ee8ea
> > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/175081
> > Commit-Queue: Tommi <tommi@webrtc.org>
> > Reviewed-by: Sebastian Jansson <srte@webrtc.org>
> > Cr-Commit-Position: refs/heads/master@{#31256}
> 
> TBR=tommi@webrtc.org,srte@webrtc.org
> 
> Change-Id: I17a12bdca888a63f2fd161da30c0def5b9c3d04e
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: none
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/175103
> Reviewed-by: Artem Titov <titovartem@webrtc.org>
> Commit-Queue: Artem Titov <titovartem@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#31258}

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

# Not skipping CQ checks because this is a reland.

Bug: none
Change-Id: I23992643126d7d6dae63da1bb14420b2b8794fd9
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/175135
Reviewed-by: Tommi <tommi@webrtc.org>
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Commit-Queue: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31283}
2020-05-15 18:22:53 +00:00
Artem Titov
af1b9ceb62 Revert "Revert back to using the task_queue_ for guarding access."
This reverts commit 475006d4a3.

Reason for revert: Speculative revert. Breaks downstream project

Original change's description:
> Revert back to using the task_queue_ for guarding access.
> 
> This removes the SequenceChecker that was temporarily used while
> the rtc::Thread TQ implementation was being fixed.
> 
> Bug: none
> Change-Id: Iaa46e47371211ac0a97b2dcaf23cef12b43ee8ea
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/175081
> Commit-Queue: Tommi <tommi@webrtc.org>
> Reviewed-by: Sebastian Jansson <srte@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#31256}

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

Change-Id: I17a12bdca888a63f2fd161da30c0def5b9c3d04e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: none
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/175103
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31258}
2020-05-14 13:52:53 +00:00
Tommi
475006d4a3 Revert back to using the task_queue_ for guarding access.
This removes the SequenceChecker that was temporarily used while
the rtc::Thread TQ implementation was being fixed.

Bug: none
Change-Id: Iaa46e47371211ac0a97b2dcaf23cef12b43ee8ea
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/175081
Commit-Queue: Tommi <tommi@webrtc.org>
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31256}
2020-05-14 12:54:54 +00:00
Tommi
a0a4480f12 Migrate CallStats and RtpStreamsSynchronizer timers over to RepeatingTask
Bug: none
Change-Id: Ib49a3de74c6d3a6d4ea158383a5e4b69a1e58ab9
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/175000
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Commit-Queue: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31252}
2020-05-14 09:58:22 +00:00
Mirko Bonadei
317a1f09ed Use std::make_unique instead of absl::make_unique.
WebRTC is now using C++14 so there is no need to use the Abseil version
of std::make_unique.

This CL has been created with the following steps:

git grep -l absl::make_unique | sort | uniq > /tmp/make_unique.txt
git grep -l absl::WrapUnique | sort | uniq > /tmp/wrap_unique.txt
git grep -l "#include <memory>" | sort | uniq > /tmp/memory.txt

diff --new-line-format="" --unchanged-line-format="" \
  /tmp/make_unique.txt /tmp/wrap_unique.txt | sort | \
  uniq > /tmp/only_make_unique.txt
diff --new-line-format="" --unchanged-line-format="" \
  /tmp/only_make_unique.txt /tmp/memory.txt | \
  xargs grep -l "absl/memory" > /tmp/add-memory.txt

git grep -l "\babsl::make_unique\b" | \
  xargs sed -i "s/\babsl::make_unique\b/std::make_unique/g"

git checkout PRESUBMIT.py abseil-in-webrtc.md

cat /tmp/add-memory.txt | \
  xargs sed -i \
  's/#include "absl\/memory\/memory.h"/#include <memory>/g'
git cl format
# Manual fix order of the new inserted #include <memory>

cat /tmp/only_make_unique | xargs grep -l "#include <memory>" | \
  xargs sed -i '/#include "absl\/memory\/memory.h"/d'

git ls-files | grep BUILD.gn | \
  xargs sed -i '/\/\/third_party\/abseil-cpp\/absl\/memory/d'

python tools_webrtc/gn_check_autofix.py \
  -m tryserver.webrtc -b linux_rel

# Repead the gn_check_autofix step for other platforms

git ls-files | grep BUILD.gn | \
  xargs sed -i 's/absl\/memory:memory/absl\/memory/g'
git cl format

Bug: webrtc:10945
Change-Id: I3fe28ea80f4dd3ba3cf28effd151d5e1f19aff89
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/153221
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29209}
2019-09-17 15:47:29 +00:00
Sebastian Jansson
b55015e4e1 Replacing SequencedTaskChecker with SequenceChecker.
Bug: webrtc:9883
Change-Id: I5e3189da2a46e6f4ed1a3c5a5dfd2f7d75a16b5d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/130961
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27518}
2019-04-09 12:28:04 +00:00
Sebastian Jansson
46b4a0f3fa Removes PostStop from RepeatingTaskHandle.
It isn't used and can easily be replaced with posting a task, as shown
in the changes to the unit test.

Also removing the sequenced task checker that no longer adds any value.
We now ensure that the task can only be stopped with a reference to the
 task queue it runs on.

Bug: webrtc:10365
Change-Id: Ie8aef6f742c55db1fb686f20c2a28c606c721fa0
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/129725
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27292}
2019-03-26 14:59:56 +00:00
Sebastian Jansson
793597b7c9 Removes TaskQueueBase::Current call in repeating task.
Bug: webrtc:10365
Change-Id: Ie9fd1a28e96680b8b4b6ef8339c3eaba21ef9e18
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/126781
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27092}
2019-03-13 08:17:22 +00:00
Danil Chapovalov
4423c36448 Migrate RepeatingTask to take raw pointer to TaskQueueBase instead of TaskQueue
In particular replace call rtc::TaskQueue::Current with TaskQueueBase::Current

Bug: webrtc:10191
Change-Id: I19d42a716d27f0aba087dc70ac65b4ee6249408f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/125085
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27005}
2019-03-06 18:44:35 +00:00
Sebastian Jansson
ecb6897ade Adds repeating task class.
This CL adds a single class to manage the use case of having a task
that repeats itself by a fixed or variable interval. It replaces the
repeating task previously locally defined for rtp transport controller
send as well as the cancelable periodic task. Furthermore, it is
introduced where one off repeating tasks were created before.

It provides the currently used functionality of the cancelable periodic
task, but not some of the unused features, such as allowing cancellation
of tasks before they are started and cancellation of a task after the
owning task queue has been destroyed.

Bug: webrtc:9883
Change-Id: Ifa7edee836c2a64fce16a7d0f682eb09c879eaca
Reviewed-on: https://webrtc-review.googlesource.com/c/116182
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26313}
2019-01-18 10:55:41 +00:00