0
Commit Graph

74 Commits

Author SHA1 Message Date
Egor Pasko
049e8d35d8 docs: threading_and_tasks.md: Clarify with more examples
Clarify the memory ordering explainer with more examples and references
to common practices in Chrome.

Bug: None
Change-Id: I0459da0b4a4bdd1bb1f9836ba8a30e2735c485fe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4283738
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Egor Pasko <pasko@chromium.org>
Auto-Submit: Egor Pasko <pasko@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1108998}
2023-02-23 17:09:50 +00:00
Egor Pasko
7f58c33bd4 docs: threading: Explain memory ordering guarantees of PostTask
Bug: None
Change-Id: I50ed5486a818e9e359f7fed00a421e89c186da7d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4261928
Commit-Queue: Egor Pasko <pasko@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1106742}
2023-02-17 13:19:56 +00:00
Francois Doray
a06ee176c7 Remove remaining uses of ScopedNestableTaskAllower.
ScopedNestableTaskAllower allows application tasks in native loops and
RunLoops that run within its scope. It is deprecated.

  If the intent is to allow application tasks in a native loop, it
  should be replaced with ScopedAllowApplicationTasksInNativeNestedLoop.

  If the intent is to allow application tasks in a RunLoop, the RunLoop
  should be constructed with Type::kNestableTasksAllowed.

  If no loop (native or RunLoop) runs within the scope of the
  ScopedNestableTaskAllower, it should just be removed.

We manually inspected the code to determine the appropriate replacement
for each remaining use.

Bug: 781352
Change-Id: I007bd0a0f9d6aa938f879f48864a9400808d486b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4035451
Reviewed-by: Gabriel Charette <gab@chromium.org>
Owners-Override: Gabriel Charette <gab@chromium.org>
Commit-Queue: Francois Pierre Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1075631}
2022-11-24 21:09:18 +00:00
Xiaohan Wang
5279ee07b6 Fix test example in threading_and_tasks.md
It should be TEST_F since it uses a test fixture.

Change-Id: Ib81a04c656d57b3ff1cf3594cc8c8d62e4adfcab
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3965462
Auto-Submit: Xiaohan Wang <xhwang@chromium.org>
Commit-Queue: Xiaohan Wang <xhwang@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1061272}
2022-10-19 22:21:06 +00:00
Sean Maher
03efef1173 Task Posting v3: migrate (Sequenced|Thread)TaskRunnerHandle
To migrate to v3 task posting API, this CL moves moves
(Sequenced|Thread)TaskRunnerHandle::Get() to
(Sequenced|SingleThread)TaskRunner::GetCurrentDefault()
and related classes. For more detail on this migration, refer to
https://docs.google.com/document/d/1tssusPykvx3g0gvbvU4HxGyn3MjJlIylnsH13-Tv6s4/edit#bookmark=id.1umyn7v5a4p

The blink codebase's presubmits were substantially changed. This was
done because the presubmit did not parse in-class identifiers, and so
there was no way of banning inner classes/methods/identifiers of a
class which is allowed.

The reason this was needed for this CL is that
base::(Sequenced|SingleThread)TaskRunners are permitted in blink, but
we need to ban (Sequenced|SingleThread)TaskRunner::GetCurrentDefault()
and [...]::CurrentDefaultHandle to ensure that tasks in blink remain
properly labeled.

To this end, a new type of identifier (in-class identifiers, such as
nested::namespace::ClassName::EnumClassName) is parsed by the
presubmit, and a new kind of rule can be added to the _CONFIG file to
allow/deny them. They are parsed very similarly to the existing
identifiers, but crucially, they are allowed by default, whereas
ClassNames are denied by default.

In addition, the tests for the presubmit were mostly rewritten to
properly test whether the identifiers in the test are actually
allowed/disallowed. Instead of simply testing to see whether an
identifier is present in _CONFIG in the presubmit file, the
presubmit's functions are called in the same way as happens during the
presubmit to make sure the code being run actually works.

Finally, it also tests that the identifiers tested are fully parsed
(a handful of them weren't because they were either preceded by '::'
or in-class) by the presubmit.

The task runner handle classes still exist in the codebase, and no
existing Chromium code has been modified, as semantics have been
preserved despite the implementation change.

The implementation migration will then take place in future CLs.
Because the two APIs expose the same functionality, the codebase
can be incrementally migrated.

Bug: 1026641
Change-Id: I7ea7bb36f30ecd3cdefedcffd8bae16118b0f3d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3804911
Reviewed-by: Francois Pierre Doray <fdoray@chromium.org>
Commit-Queue: Sean Maher <spvw@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1050813}
2022-09-23 22:43:13 +00:00
Gabriel Charette
9b6c0407ac [base] Cleanup remaining mentions of post_task.h
Bug: 1026641
Change-Id: I2bbd0822ad045651d10bd66ce81fe0fb99ff3de2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3565099
Reviewed-by: Avi Drissman <avi@chromium.org>
Reviewed-by: Rohit Rao <rohitrao@chromium.org>
Reviewed-by: Ken Rockot <rockot@google.com>
Reviewed-by: Francois Pierre Doray <fdoray@chromium.org>
Commit-Queue: Francois Pierre Doray <fdoray@chromium.org>
Owners-Override: Francois Pierre Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/main@{#988170}
2022-04-01 23:22:46 +00:00
Eugene Zemtsov
48b30d388d Fix doc, GetWeakPtr() can be called from another sequence
Only referencing  and invalidation need to happen on the same sequence.

Change-Id: Ifeeeb3252e49c89208dc2403777e2bc2b4c04e4c
Source: comment in weak_ptr.h
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3531087
Reviewed-by: Gabriel Charette <gab@chromium.org>
Commit-Queue: Eugene Zemtsov <eugene@chromium.org>
Cr-Commit-Position: refs/heads/main@{#982963}
2022-03-18 23:56:11 +00:00
cfredric
ff6d86c0f4 Add link to concurrency-in-chromium slide deck.
Change-Id: I022e0d2b43209769c62703cb073002696944aed4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3459523
Reviewed-by: Gabriel Charette <gab@chromium.org>
Commit-Queue: Chris Fredrickson <cfredric@chromium.org>
Cr-Commit-Position: refs/heads/main@{#971250}
2022-02-15 16:26:11 +00:00
Gabriel Charette
bd126bc322 [docs] Mention bit.ly/run-until-idle-with-care2 in threading docs
R=fdoray@chromium.org, sebmarchand@google.com

Change-Id: I1862d90764f5d3f0f3ae851be170ffa4e9deb880
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3426644
Commit-Queue: Gabriel Charette <gab@chromium.org>
Auto-Submit: Gabriel Charette <gab@chromium.org>
Reviewed-by: Sébastien Marchand <sebmarchand@chromium.org>
Commit-Queue: Sébastien Marchand <sebmarchand@chromium.org>
Cr-Commit-Position: refs/heads/main@{#965770}
2022-02-01 18:19:19 +00:00
Patrick Monette
2d93ad9012 Fix references to moved files in documentation.
Bug: 1255932
Change-Id: Id76970abfa7262ede732ff0d1ffefa36e4a8f5a0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3219351
Reviewed-by: John Chen <johnchen@chromium.org>
Reviewed-by: Jeremy Roman <jbroman@chromium.org>
Reviewed-by: Eric Orth <ericorth@chromium.org>
Commit-Queue: Patrick Monette <pmonette@chromium.org>
Cr-Commit-Position: refs/heads/main@{#936987}
2021-11-01 19:20:22 +00:00
Peter Kasting
53fd6ee437 TimeDelta factory function migration.
To aid conversions, first removed "using base::TimeDelta;" and converted
TimeDelta to base::TimeDelta in the affected files.  Then converted all
TimeDelta::FromX() and TimeDelta().FromX() (!) into X().

The changes in this CL were all performed by tools; no manual
interventions occurred.

Bug: 1243777
Change-Id: Iddcb80d7883fd494d2209d01945a6553f316ff95
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3202380
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Owners-Override: Peter Kasting <pkasting@chromium.org>
Reviewed-by: Peter Boström <pbos@chromium.org>
Cr-Commit-Position: refs/heads/main@{#928323}
2021-10-05 20:40:48 +00:00
Peter Kasting
e5a38eddbd Migrate "base::TimeDelta::FromX" to "base:X".
All changes were done automatically with git grep, sed, xargs, etc.

No-Presubmit: true
No-Try: true
Bug: 1243777
Change-Id: I7cc197e9027f7837cd36afc67a209079f85ec364
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3198824
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Owners-Override: Peter Kasting <pkasting@chromium.org>
Reviewed-by: Peter Boström <pbos@chromium.org>
Cr-Commit-Position: refs/heads/main@{#927512}
2021-10-02 03:06:35 +00:00
Matt Falkenhagen
72a2dfc77e docs: Update Threading and Tasks to describe modern UI and IO thread.
The browser process no longer does network requests on the IO thread.
Also expand on what "handles IPC" means as often Mojo interfaces are
not on the IO thread.

Change-Id: I7e449cda99b4527316c27bf8e1557fa030877ff0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3061781
Commit-Queue: Matt Falkenhagen <falken@chromium.org>
Reviewed-by: Ken Rockot <rockot@google.com>
Cr-Commit-Position: refs/heads/master@{#909087}
2021-08-05 22:36:13 +00:00
Jared Saul
ea867ab3df Threading and tasks doc update; typo/etc. fixes
Change-Id: I733a44bf598192ffef193f9732e468147f146970
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3027543
Commit-Queue: Jared Saul <jsaul@google.com>
Reviewed-by: Etienne Pierre-Doray <etiennep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#902021}
2021-07-15 17:39:01 +00:00
Erik Chen
0ee26a3d2b Doc update for threading_and_tasks.md.
Fixed typo

Change-Id: Id2465cc6cd84f74a58b70e4f1930689fcfa47dff
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3028496
Commit-Queue: Alexander Timin <altimin@chromium.org>
Reviewed-by: Alexander Timin <altimin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#901585}
2021-07-14 20:04:47 +00:00
Albert J. Wong
f06ff5007b Clarifying the use of Concurrent vs Parallel
Chrome is a highly concurrent system that uses parallelism when we're
forced to.

https://stackoverflow.com/questions/1050222/what-is-the-difference-between-concurrency-and-parallelism#:~:text=Concurrency%20is%20when%20two%20or,e.g.%2C%20on%20a%20multicore%20processor

Change-Id: I6554f434ab5d4eaae7c774533b8436cdb3224db9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2669208
Reviewed-by: Gabriel Charette <gab@chromium.org>
Reviewed-by: Etienne Pierre-Doray <etiennep@chromium.org>
Reviewed-by: Albert J. Wong <ajwong@chromium.org>
Commit-Queue: Albert J. Wong <ajwong@chromium.org>
Auto-Submit: Albert J. Wong <ajwong@chromium.org>
Cr-Commit-Position: refs/heads/master@{#899691}
2021-07-08 20:37:00 +00:00
Francois Doray
f652a9d063 [documentation] Fix nit in threading_and_tasks.md.
The text was referring to the wrong function name.

Change-Id: I8f3d201890b0d0165f699fa85f73d07fdbc06ef8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3009074
Auto-Submit: François Doray <fdoray@chromium.org>
Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org>
Reviewed-by: Etienne Pierre-Doray <etiennep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#898824}
2021-07-06 13:07:52 +00:00
Wen Fan
e09439cad3 fix the document issue
fix the document issue caused by mechanical change.

Bug: 1151321
Change-Id: I0149d171a033f10ed6c335383e0e28bddd6c77b8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2731031
Reviewed-by: Carlos Caballero <carlscab@google.com>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Commit-Queue: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#861178}
2021-03-09 16:50:41 +00:00
Alex St-Onge
490a97a79d Update threading_and_tasks.md to favor OnceCallback and RepeatingCallback
Bug: 1172520
Change-Id: I7c69502d8a5d02e07dffe4d9cad575db0f399cf2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2673012
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#850425}
2021-02-04 02:47:19 +00:00
Etienne Pierre-Doray
f91d7a0b4e [Jobs]: Follow-up on "Expose worker count to Job users"
Addressing gab comments on
https://chromium-review.googlesource.com/c/chromium/src/+/2304972

Change-Id: I4ac6d2378bdf509c3c606d0bafab965212f07638
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2390860
Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#806199}
2020-09-11 15:53:27 +00:00
Etienne Pierre-doray
2f52b351aa [Jobs API]: Expose worker count to Job users.
Add JobHandle::IsComplete and pass worker_count as argument to
max_concurrency_callback.
To make better use of worker_lock, and accommodate worklist use case by
exposing worker count:
- worker_count is used in max_concurrency_callback in cases where the
  return value is inferred from it. In the worklist case, each active
  worker keep a local segment not visible globally, so worker_count is
  added to the global queue size.
- IsComplete is used to make sure that no work is pending. In the
  worklist case, checking that we're done involves checking that the
  global queue is empty AND that worker_count == 0 (atomically), which
  is a lot easier when |worker_lock| is taken. This is used e.g. in
  marking to switch phase (we don't want to cancel or join) where we
  stop creating work.

Bug: 1114823
Change-Id: I5efc5622aa70e731981a958a066ab56567c603ed
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2304972
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Reviewed-by: Jochen Eisinger <jochen@chromium.org>
Reviewed-by: François Doray <fdoray@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#797359}
2020-08-12 19:04:29 +00:00
Carlos Caballero
b25fe847c7 Rename MessageLoopCurrent to CurrentThread
Get rid of all references to MessageLoopCurrent(ForIO|ForUI)

This is a mechanical change. Just ran the following commands

mffr.py base/message_loop/message_loop_current base/task/current_thread
mffr.py -f MessageLoopCurrentForUI CurrentUIThread
mffr.py -f MessageLoopCurrentForIO CurrentIOThread
mffr.py -f MessageLoopCurrent CurrentThread
rm base/message_loop/message_loop_current.h

This patch will be reviewed according to
https://chromium.googlesource.com/chromium/src/+/master/docs/code_reviews.md#mechanical-changes

TBR=gab@chromium.org

Bug: 891670
Change-Id: If3892558ad71333f93a4698ac5411f141ccd5657
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2279990
Commit-Queue: Carlos Caballero <carlscab@google.com>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#789421}
2020-07-17 10:27:17 +00:00
Carlos Caballero
4a05092f8e Deprecate MessageLoopCurrent in favor of CurrentThread
Followup patches will migrate code to the new names and header files.

Bug: 891670
Change-Id: I35c3aa51236f8d0934d87d699e6298494ded14b8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2270327
Commit-Queue: Carlos Caballero <carlscab@google.com>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#784774}
2020-07-02 11:43:38 +00:00
Carlos Caballero
40b6d04fa7 Reland "MessageLoop, you are terminated \o/"
This is a reland of a300f0f263

keeping message_loop_unittest.cc in the BUILD file (for now) and some
test renames that were missing

Original change's description:
> MessageLoop, you are terminated \o/
>
> https://youtu.be/iy_BBBGBpqA
>
> Bug: 891670
> Change-Id: If420ee295c5bf4934a093613bbc7a8a0311ba620
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1964373
> Commit-Queue: Carlos Caballero <carlscab@google.com>
> Reviewed-by: Gabriel Charette <gab@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#778248}

Bug: 891670
Change-Id: I96e26a402bdb1b1cc0616dda153d10000cf39a54
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2246173
Reviewed-by: Gabriel Charette <gab@chromium.org>
Commit-Queue: Carlos Caballero <carlscab@google.com>
Cr-Commit-Position: refs/heads/master@{#778674}
2020-06-16 06:50:25 +00:00
Carlos Caballero
4865a3bbfa Revert "MessageLoop, you are terminated \o/"
This reverts commit a300f0f263.

Reason for revert: Removed message_loop_unittests.cc from the BUILD file by mistake. This will happen in a follow up patch along with the rename.

Original change's description:
> MessageLoop, you are terminated \o/
> 
> https://youtu.be/iy_BBBGBpqA
> 
> Bug: 891670
> Change-Id: If420ee295c5bf4934a093613bbc7a8a0311ba620
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1964373
> Commit-Queue: Carlos Caballero <carlscab@google.com>
> Reviewed-by: Gabriel Charette <gab@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#778248}

TBR=gab@chromium.org,carlscab@google.com

Change-Id: I7e6036bcbf7559769b4db41ecb012b82875b90c3
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 891670
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2245908
Reviewed-by: Carlos Caballero <carlscab@google.com>
Commit-Queue: Carlos Caballero <carlscab@google.com>
Cr-Commit-Position: refs/heads/master@{#778300}
2020-06-15 15:26:45 +00:00
Carlos Caballero
a300f0f263 MessageLoop, you are terminated \o/
https://youtu.be/iy_BBBGBpqA

Bug: 891670
Change-Id: If420ee295c5bf4934a093613bbc7a8a0311ba620
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1964373
Commit-Queue: Carlos Caballero <carlscab@google.com>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#778248}
2020-06-15 11:04:01 +00:00
Etienne Pierre-doray
6d3cd919c4 [Jobs]: Jobs perftests
This CL adds Jobs API perftests as a way to show use case and
measure performance overhead.

Local results (mac laptop):

Naive:
No-Op = 4627 tasks/ms
BusyWait = 793 tasks/ms

Dynamic:
No-Op= 14771 tasks/ms
No-Op disrupted= 14285 tasks/ms
BusyWait= 791 tasks/ms
BusyWait+disrupted= 750 tasks/ms

Loop around:
No-Op= 14044 tasks/ms
No-Op disrupted= 13386 tasks/ms
BusyWait= 773 tasks/ms
BusyWait disrupted= 729 tasks/ms

Change-Id: I0d625293fa95dc5a4f4f8dfc01eb84b9b5d438f1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1943539
Reviewed-by: Gabriel Charette <gab@chromium.org>
Reviewed-by: François Doray <fdoray@chromium.org>
Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756817}
2020-04-06 21:10:37 +00:00
Gabriel Charette
de41cad998 [base] Remove already-disabled priority-inheritance logic
Analysis of experiment results:
https://docs.google.com/document/d/13PIBPuSPJbrgHAgyRbY22EWAfH2narnxpa_CgBmZbSY/edit#heading=h.4fo2tzjehwu7

Updated documentation accordingly.

The Java changes should be no-ops (the previous Java default was
left as USER_VISIBLE unintentionally in crrev.com/664726 but never
kicked in when !mPrioritySetExplicitly).

R=fdoray@chromium.org

Fixed: 1022972
Change-Id: Iab8219e68ab703e0cc9ceeb16ef70b78cf43a50a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2063150
Commit-Queue: Avi Drissman <avi@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Reviewed-by: François Doray <fdoray@chromium.org>
Reviewed-by: Richard Coles <torne@chromium.org>
Reviewed-by: Sami Kyöstilä <skyostil@chromium.org>
Reviewed-by: Alexander Timin <altimin@chromium.org>
Auto-Submit: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#746440}
2020-03-03 18:05:06 +00:00
Olivier Li
56b99d4ef1 Fix typo in Threading and Tasks doc
Change-Id: Ib3b297674c11fd9d3ed71a775b681ba6d2f65fab
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2041873
Auto-Submit: Oliver Li <olivierli@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Commit-Queue: Oliver Li <olivierli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#740283}
2020-02-11 13:51:41 +00:00
Wez
9d5dd28085 Reland "[base] Make test Run() timeouts fatal unless using GTest."
This is a reland of
https://chromium-review.googlesource.com/c/chromium/src/+/1932464 with
a missing #include added to assistant_test_mixin.cc.

The Run() timeouts set for tests now default to crashing the calling
process. This ensures that Run() timeouts cause visible failures
regardless of whether the calling suite uses GTest.  Suites which do use
GTest can switch to having timeouts reported via GTEST_FAIL() by calling:

  base::test::ScopedRunLoopTimeout::SetUseGTestFailOnTimeout();

Test suites derived from base::TestSuite will have this option set for
them as part of the TestSuite initialization.

The RunLoop::ScopedRunTimeoutForTest helper is moved to
base::test::ScopedRunLoopTimeout, to allow it to have GTest dependencies.

TBR=gab@chromium.org,kmarshall@chromium.org

Cq-Include-Trybots: luci.chrome.try:linux-chromeos-chrome
Bug: 1021777, 1014767
Change-Id: I1f6674913e06607b07c40020341a9e25ef75b72e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2044082
Auto-Submit: Wez <wez@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Wez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#739911}
2020-02-10 17:21:22 +00:00
Takashi Sakamoto
21fa8d0bbd Revert "[base] Make test Run() timeouts fatal unless using GTest."
This reverts commit e7f522eeb9.

Reason for revert: suspect causing compile failure on linux-chromeos-chrome.

Sample build: https://ci.chromium.org/p/chrome/builders/ci/linux-chromeos-chrome/2923

Sample log: https://logs.chromium.org/logs/chrome/buildbucket/cr-buildbucket.appspot.com/8888898680396285712/+/steps/compile/0/stdout?format=raw

E.g.
../../chrome/browser/ui/ash/assistant/assistant_test_mixin.cc:323:42: error: variable has incomplete type 'const base::test::ScopedRunLoopTimeout'
  const base::test::ScopedRunLoopTimeout run_timeout(wait_timeout);
                                         ^
../../base/run_loop.h:28:7: note: forward declaration of 'base::test::ScopedRunLoopTimeout'
class ScopedRunLoopTimeout;
      ^
../../chrome/browser/ui/ash/assistant/assistant_test_mixin.cc:356:42: error: variable has incomplete type 'const base::test::ScopedRunLoopTimeout'
  const base::test::ScopedRunLoopTimeout run_timeout(wait_timeout);
                                         ^
../../base/run_loop.h:28:7: note: forward declaration of 'base::test::ScopedRunLoopTimeout'
class ScopedRunLoopTimeout;
      ^
../../chrome/browser/ui/ash/assistant/assistant_test_mixin.cc:371:42: error: variable has incomplete type 'const base::test::ScopedRunLoopTimeout'
  const base::test::ScopedRunLoopTimeout run_timeout(wait_timeout);
                                         ^
../../base/run_loop.h:28:7: note: forward declaration of 'base::test::ScopedRunLoopTimeout'
class ScopedRunLoopTimeout;
      ^
3 errors generated.


Original change's description:
> [base] Make test Run() timeouts fatal unless using GTest.
> 
> The Run() timeouts set for tests now default to crashing the calling
> process. This ensures that Run() timeouts cause visible failures
> regardless of whether the calling suite uses GTest.  Suites which do use
> GTest can switch to having timeouts reported via GTEST_FAIL() by calling:
> 
>   base::test::ScopedRunLoopTimeout::SetUseGTestFailOnTimeout();
> 
> Test suites derived from base::TestSuite will have this option set for
> them as part of the TestSuite initialization.
> 
> The RunLoop::ScopedRunTimeoutForTest helper is moved to
> base::test::ScopedRunLoopTimeout, to allow it to have GTest dependencies.
> 
> Bug: 1021777, 1014767
> Change-Id: Id372c666c6455e56e52034ae528b417a0c23143c
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1932464
> Commit-Queue: Wez <wez@chromium.org>
> Auto-Submit: Wez <wez@chromium.org>
> Reviewed-by: Scott Violet <sky@chromium.org>
> Reviewed-by: Gabriel Charette <gab@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#739760}

TBR=sky@chromium.org,wez@chromium.org,gab@chromium.org,kmarshall@chromium.org

Change-Id: Ib0927699042f216971448da8b1d70619c0545367
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1021777, 1014767
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2045697
Reviewed-by: Takashi Sakamoto <tasak@google.com>
Commit-Queue: Takashi Sakamoto <tasak@google.com>
Cr-Commit-Position: refs/heads/master@{#739790}
2020-02-10 04:58:55 +00:00
Wez
e7f522eeb9 [base] Make test Run() timeouts fatal unless using GTest.
The Run() timeouts set for tests now default to crashing the calling
process. This ensures that Run() timeouts cause visible failures
regardless of whether the calling suite uses GTest.  Suites which do use
GTest can switch to having timeouts reported via GTEST_FAIL() by calling:

  base::test::ScopedRunLoopTimeout::SetUseGTestFailOnTimeout();

Test suites derived from base::TestSuite will have this option set for
them as part of the TestSuite initialization.

The RunLoop::ScopedRunTimeoutForTest helper is moved to
base::test::ScopedRunLoopTimeout, to allow it to have GTest dependencies.

Bug: 1021777, 1014767
Change-Id: Id372c666c6455e56e52034ae528b417a0c23143c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1932464
Commit-Queue: Wez <wez@chromium.org>
Auto-Submit: Wez <wez@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#739760}
2020-02-09 20:36:05 +00:00
Gabriel Charette
1138d6022d [ThreadPool] Fix docs to match new API
R=etiennep@chromium.org

Bug: 1026641
Change-Id: I68c6e40f080ac5808cd9c67e227695ca921e1691
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2026714
Auto-Submit: Gabriel Charette <gab@chromium.org>
Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org>
Reviewed-by: Etienne Pierre-Doray <etiennep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#736281}
2020-01-29 08:51:52 +00:00
Gabriel Charette
49e3cd0996 Introduce content::GetUIThreadTaskRunner() and its IO counterpart
As agreed upon in design doc @
https://docs.google.com/document/d/1tssusPykvx3g0gvbvU4HxGyn3MjJlIylnsH13-Tv6s4/edit?ts=5e1c66d5&pli=1#bookmark=id.ll79iqi5rlpp

base::ThreadPool counterpart to move away from post_task.h is @
https://chromium-review.googlesource.com/c/chromium/src/+/1977964

API usage migration will be done in a follow-up mega CL.
This CL at least uses it in its own tests.

See https://chromium-review.googlesource.com/c/chromium/src/+/2015655
for how this will look in practice for a few callsites.

Bug: 1026641
Change-Id: I98771fd68a513bf0a4776672a8d75fcbbb200bea
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2014055
Commit-Queue: Gabriel Charette <gab@chromium.org>
Reviewed-by: Alexander Timin <altimin@chromium.org>
Reviewed-by: François Doray <fdoray@chromium.org>
Reviewed-by: Darin Fisher <darin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#735734}
2020-01-28 03:45:27 +00:00
Gabriel Charette
43de5c41e2 [base/task] Introduce base::ThreadPool:: for Task APIs v3.
Design doc : https://docs.google.com/document/d/1tssusPykvx3g0gvbvU4HxGyn3MjJlIylnsH13-Tv6s4/edit

BrowserThread counterpart to move away from post_task.h is @
https://chromium-review.googlesource.com/c/chromium/src/+/2014055

Bug: 1026641
Change-Id: I11c0633779cd2cfe75e29d3318b953c86e32bbec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1977964
Commit-Queue: Gabriel Charette <gab@chromium.org>
Reviewed-by: François Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#735609}
2020-01-27 22:44:45 +00:00
Etienne Pierre-doray
d388299af7 [ThreadPool]: Add section on Jobs API in threading_and_tasks.md
Change-Id: Iab598deb78a0716543b3ed2c1af2f57fd7f0ab81
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1998972
Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Reviewed-by: François Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#731574}
2020-01-14 20:34:11 +00:00
Alexander Timin
e653dfcc44 Revert "Implement base::GetContinuationTaskRunner()."
This reverts commit 0dd4995617.

Reason for revert:

Remove the ability to get the current task runner according to 
the recent discussions in scheduler-dev@ [1].

[1] https://docs.google.com/document/d/1tssusPykvx3g0gvbvU4HxGyn3MjJlIylnsH13-Tv6s4/edit

R=gab@chromium.org,darin@chromium.org,alexclarke@chromium.org
BUG=1026641

Original change's description:
> Implement base::GetContinuationTaskRunner().
> 
> This returns to the current task's task runner. Note there are some
> situations where this is not valid:
> 
> * When we're not running a task (it will DCHECK).
> * When we're in a one-off base::ThreadPool task (it will DCHECK).
> * In non-scheduler backed threads (it will DCHECK).
> 
> Bug: 835323
> Change-Id: I3a789557247240e0c36a47339574350d79746144
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1834094
> Commit-Queue: Gabriel Charette <gab@chromium.org>
> Reviewed-by: Gabriel Charette <gab@chromium.org>
> Reviewed-by: Rohit Rao <rohitrao@chromium.org>
> Reviewed-by: François Doray <fdoray@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#707484}

TBR=rohitrao@chromium.org,gab@chromium.org,fdoray@chromium.org,alexclarke@chromium.org

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

Bug: 835323
Change-Id: I233ff3ba4e2f20e23a67a3bf6c46734608144eca
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1959917
Reviewed-by: Alexander Timin <altimin@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Commit-Queue: Alexander Timin <altimin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#728982}
2020-01-07 17:55:06 +00:00
Gabriel Charette
fee5566491 [Task APIs] Stop the bleeding while design discussions are in-progress
We had landed the previously agreed upon API but recent design
discussions have invalidated previous decisions. To stop the bleeding
let's at least revert the documentation until we have a fully
approved plan.

R=altimin@chromium.org, darin@chromium.org

Bug: 1026641
Change-Id: Idf0c2deafbd7fcd85541272f04fcd93cc745ce73
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1926533
Commit-Queue: Gabriel Charette <gab@chromium.org>
Reviewed-by: Darin Fisher <darin@chromium.org>
Reviewed-by: Alexander Timin <altimin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#717214}
2019-11-20 21:06:28 +00:00
Alex Clarke
0dd4995617 Implement base::GetContinuationTaskRunner().
This returns to the current task's task runner. Note there are some
situations where this is not valid:

* When we're not running a task (it will DCHECK).
* When we're in a one-off base::ThreadPool task (it will DCHECK).
* In non-scheduler backed threads (it will DCHECK).

Bug: 835323
Change-Id: I3a789557247240e0c36a47339574350d79746144
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1834094
Commit-Queue: Gabriel Charette <gab@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Reviewed-by: Rohit Rao <rohitrao@chromium.org>
Reviewed-by: François Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#707484}
2019-10-18 19:45:09 +00:00
Gabriel Charette
0b20ee6ca6 Add "Testing Components Which Post Tasks" docs
This is the complimentary testing docs to the Threading and Tasks usage
docs.

Updated in-code comments to reflect the current reality better too.

R=fdoray@chromium.org

Bug: 1002654
Change-Id: Ic9f4227e462ddc7180a1a6f3005935f1203ff064
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1798985
Auto-Submit: Gabriel Charette <gab@chromium.org>
Reviewed-by: Etienne Pierre-Doray <etiennep@chromium.org>
Reviewed-by: François Doray <fdoray@chromium.org>
Reviewed-by: Elly Fong-Jones <ellyjones@chromium.org>
Commit-Queue: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#697592}
2019-09-18 14:06:12 +00:00
Gabriel Charette
798fde7bc9 [Browser/WebTaskEnvironment] Mass-migrate away from Test(Browser|Web)ThreadBundle
This is
 1) s/TestBrowserThreadBundle/BrowserTaskEnvironment/ on src/
 2) s/([^/])\b\w*thread_bundle(_)?/\1task_environment\2/ on files modified in (1)
 3) git cl format
 4) Manually fix up remainder "ThreadBundle" and "thread_bundle" found via
    string search on the whole of src/.

For ease of review:
 * Step  is the diff between patch sets 1..2
 * Step  is the diff between patch sets 2..3

TBR=dcheng@chromium.org
(for post-review owners bypass per mechanical change)

Bug: 992483
Change-Id: I4945141f6d78bdc6c98444198e5012ddc8e5bff0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1758440
Reviewed-by: Gabriel Charette <gab@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Gabriel Charette <gab@chromium.org>
Auto-Submit: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#688755}
2019-08-20 22:24:04 +00:00
Gabriel Charette
694c3c33ca [TaskEnvironment] Mass-migrate away from ScopedTaskEnvironment (1/2)
(well half of them because git cl upload wouldn't let me do
 them all at once...)

This is step  of the mass migration. Some of these will be
backported to SingleThreadTaskEnvironment in a later phase.

scoped_task_environment.h will also only move in a follow-up CL.

TBR=dcheng@chromium.org

Bug: 992483
Change-Id: I44bc376deee9b6c95bafac8d54165174d86a5001
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1756247
Reviewed-by: Gabriel Charette <gab@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#688086}
2019-08-19 14:53:05 +00:00
Sami Kyostila
831c60b09f docs: Remove "WithTraits" suffix from task posting documentation
Bug: 968047
Change-Id: Ibae113c025e4db430980c75932b8625657d096ca
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1728564
Auto-Submit: Sami Kyöstilä <skyostil@chromium.org>
Reviewed-by: Alex Clarke <alexclarke@chromium.org>
Commit-Queue: Sami Kyöstilä <skyostil@chromium.org>
Cr-Commit-Position: refs/heads/master@{#682692}
2019-07-31 13:31:23 +00:00
Jeremy Roman
0dd0b2ff12 Update WeakPtrFactory examples to use in-class initializers.
This is now the more common, and simpler, pattern.

Bug: 981415
Change-Id: I082e75425a33f6256c2ddc3228d61f8b6fe8bc58
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1704677
Reviewed-by: Gabriel Charette <gab@chromium.org>
Commit-Queue: Jeremy Roman <jbroman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#677960}
2019-07-16 21:00:43 +00:00
Drew Stonebraker
653a3bacf8 Fix broken link in docs
Test: open in gitiles in gerrit
Change-Id: If51d5c7712a4e36264b62d457370e1d95f7aba64
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1682486
Reviewed-by: François Doray <fdoray@chromium.org>
Commit-Queue: François Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#674163}
2019-07-02 19:24:23 +00:00
Dominic Farolino
dbe9769b35 [docs]: Make SingleThreadTaskRunner example more explicit
This CL makes a SingleThreadTaskRunner example more explicit by using
the SingleThreadTaskRunner type instead of using the
SequencedTaskRunner base class.

Bug: N/A
Change-Id: I77fa2affacbda0f4847e4b808eab267f0977fb49
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1636668
Reviewed-by: Marijn Kruisselbrink <mek@chromium.org>
Commit-Queue: Dominic Farolino <domfarolino@gmail.com>
Cr-Commit-Position: refs/heads/master@{#665049}
2019-05-31 04:06:03 +00:00
Gabriel Charette
43fd37033b [ThreadPool] Rename base::ThreadPool to base::ThreadPoolInstance
In order to leave the base::ThreadPool symbol available for
an upcoming "destination" task trait.

Also moved ThreadPoolImpl to be the implementation of TaskExecutor,
not ThreadPoolInstance. It was a mistake that base::ThreadPool was
implementing TaskExecutor, its users shouldn't have access to
PostTask*() and Create*TaskRunner*().

TBR=fdoray@chromium.org
(bypass owners for side-effects beyond //base)

Bug: 968047
Change-Id: I0607fba6d7f30d202bf7f61a9f461b1256e87467
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1634851
Reviewed-by: Gabriel Charette <gab@chromium.org>
Reviewed-by: François Doray <fdoray@chromium.org>
Commit-Queue: Gabriel Charette <gab@chromium.org>
Auto-Submit: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#664300}
2019-05-29 16:36:51 +00:00
Gabriel Charette
39db4c682c [base] Improve Threading and Tasks docs
Mainly:
 * Add a smoother introduction to the Core Concepts
   (the previous nomenclature section assumed knowledged of some types
    from the get-go).
 * Try to avoid using yet-to-be-defined types everywhere (or make
   references explicit).
 * Stop referring to the old-vs-new codebase as the "new" paradigms
   have been in place for a few years and the distinction is merely
   confusing newcomers.

We will also look into adding a codelab to have a storylike approach
for newcomers which will be better suited than the point-by-point
how-to.

R=fdoray@chromium.org

Change-Id: I30fb7960796164496dab77b33bc33b39692b709e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1535489
Commit-Queue: Gabriel Charette <gab@chromium.org>
Reviewed-by: François Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#654986}
2019-04-29 19:52:38 +00:00
Gabriel Charette
52fa3aed17 [base] Rename TaskScheduler to ThreadPool
Reason: with the advent of other scheduling primitives in //base
(i.e. SequenceManager), TaskScheduler was no longer the only component
responsible for scheduling tasks. We will from now on refer to the
whole of //base/task as the "task scheduling infrastructure".

There are other types named "TaskScheduler" outside of base:: so
s/TaskScheduler/ThreadPool/ across the codebase wasn't possible.

Instead, this CL did:
 1) base/task/task_scheduler => base/task/thread_pool
    (catches all files with includes)
 1.1) Careful manual search to add files without includes
      (e.g. missing IWYU, docs, etc.)
 2) TaskScheduler => ThreadPool in all files affected by (1)
 3) task_scheduler => thread_pool in all files affected by (1)
 4) "task scheduler" => "thread pool"  in all files affected by (1)
 4) Move task_scheduler_util like headers in
    //content //components and //ios

Also:
 * Renamed UMA metrics from TaskScheduler.* to ThreadPool.*
   and dropped "Pool" from worker pool name suffixes.
 * Renamed TaskScheduler*Worker thread names to ThreadPool*Worker
 * In base/android: NativeTaskScheduler => NativeScheduler as it
   was referring to the whole of base/task.
   TaskSchedulerTest.java => NativePostTaskTest.java (former DNE)
 * Intentionally ignoring IWYU violations in this already too large
   CL.

In follow-up:
 * Rename other types as well:
     SchedulerWorker => WorkerThread
     SchedulerWorkerPool* => WorkerThreadGroup*

Bug: 951388
Change-Id: I5bc2688b593c7682ef7e56d6b228539970ba107e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1561552
Commit-Queue: Gabriel Charette <gab@chromium.org>
Auto-Submit: Gabriel Charette <gab@chromium.org>
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Reviewed-by: François Doray <fdoray@chromium.org>
Reviewed-by: Ilya Sherman <isherman@chromium.org>
Reviewed-by: Richard Coles <torne@chromium.org>
Reviewed-by: Joe Mason <joenotcharles@google.com>
Reviewed-by: Etienne Pierre-Doray <etiennep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#650997}
2019-04-15 21:44:37 +00:00
Haiyang Pan
a23280217e Fixed the markdown syntax error and code path for plugin_list.cc
Change-Id: I83cc2628916875d3ea6ecd95eb19aaba2757c358
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1549980
Commit-Queue: François Doray <fdoray@chromium.org>
Reviewed-by: François Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#647234}
2019-04-03 12:07:26 +00:00