Commit d7b74986 authored by Gabriel Charette's avatar Gabriel Charette Committed by Commit Bot

Reland "Reland [base] Require task posters to specify an explicit destination"

This is a reland of dd34a877

Rebased on a few more fixes including a local full build of:
 - Windows + is_chrome_branded
 - ChromeOS + is_chrome_branded
   (except for the libassistant portion which is giving weird errors...)

Original change's description:
> Reland [base] Require task posters to specify an explicit destination
>
> This patch makes it a requirement for all task traits to specify their
> thread affinity. Previously task traits that did not name a specific
> thread would implicitly run on the thread pool, which could be
> surprising. To make this more obvious, thread pool tasks must now use
> the base::ThreadPool() trait.
>
> This is the final reland of
> https://chromium-review.googlesource.com/c/chromium/src/+/1635827
> (will attempt to fix errors that caused original revert before
>  relanding).
>
> Bug: 968047
> Change-Id: Ice339db270a27815b2be68200930e5bc105e8a96
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1759056
> Commit-Queue: Gabriel Charette <gab@chromium.org>
> Reviewed-by: François Doray <fdoray@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#688782}

Bug: 968047
Change-Id: Iccd12e0a9f1535cb10b903777c5004a7d1acb34a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1761362
Commit-Queue: Gabriel Charette <gab@chromium.org>
Reviewed-by: default avatarFrançois Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#689097}
parent cc6f61e3
...@@ -255,7 +255,16 @@ class BASE_EXPORT TaskTraits { ...@@ -255,7 +255,16 @@ class BASE_EXPORT TaskTraits {
may_block_(trait_helpers::HasTrait<MayBlock, ArgTypes...>()), may_block_(trait_helpers::HasTrait<MayBlock, ArgTypes...>()),
with_base_sync_primitives_( with_base_sync_primitives_(
trait_helpers::HasTrait<WithBaseSyncPrimitives, ArgTypes...>()), trait_helpers::HasTrait<WithBaseSyncPrimitives, ArgTypes...>()),
use_thread_pool_(trait_helpers::HasTrait<ThreadPool, ArgTypes...>()) {} use_thread_pool_(trait_helpers::HasTrait<ThreadPool, ArgTypes...>()) {
constexpr bool has_thread_pool =
trait_helpers::HasTrait<ThreadPool, ArgTypes...>();
constexpr bool has_extension =
!trait_helpers::AreValidTraits<ValidTrait, ArgTypes...>::value;
static_assert(
has_thread_pool ^ has_extension,
"Traits must explicitly specify a destination (e.g. ThreadPool or a "
"named thread like BrowserThread)");
}
constexpr TaskTraits(const TaskTraits& other) = default; constexpr TaskTraits(const TaskTraits& other) = default;
TaskTraits& operator=(const TaskTraits& other) = default; TaskTraits& operator=(const TaskTraits& other) = default;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment