thread_pool: constexpr TaskSourceSortKey()
This CL is intended to be trivial. It makes `TaskSourceSortKey` `constexpr`, bringing along a `std::array` (in a unit test) for the ride. Change-Id: Ie8d33c428b8f39b9bf483e0d18def42960f61d60 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6290268 Reviewed-by: Sean Maher <spvw@chromium.org> Auto-Submit: Kalvin Lee <kdlee@chromium.org> Commit-Queue: Kalvin Lee <kdlee@chromium.org> Cr-Commit-Position: refs/heads/main@{#1423526}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
216d6ad7cd
commit
18cae10d2c
base/task/thread_pool
@ -9,12 +9,6 @@ namespace base::internal {
|
||||
static_assert(sizeof(TaskSourceSortKey) <= 2 * sizeof(uint64_t),
|
||||
"Members in TaskSourceSortKey should be ordered to be compact.");
|
||||
|
||||
TaskSourceSortKey::TaskSourceSortKey(TaskPriority priority,
|
||||
TimeTicks ready_time,
|
||||
uint8_t worker_count)
|
||||
: priority_(priority),
|
||||
worker_count_(worker_count),
|
||||
ready_time_(ready_time) {}
|
||||
|
||||
bool TaskSourceSortKey::operator<(const TaskSourceSortKey& other) const {
|
||||
// This TaskSourceSortKey is considered more important than |other| if it has
|
||||
|
@ -15,10 +15,13 @@ namespace internal {
|
||||
// An immutable but assignable representation of the priority of a Sequence.
|
||||
class BASE_EXPORT TaskSourceSortKey final {
|
||||
public:
|
||||
TaskSourceSortKey() = default;
|
||||
TaskSourceSortKey(TaskPriority priority,
|
||||
TimeTicks ready_time,
|
||||
uint8_t worker_count = 0);
|
||||
constexpr TaskSourceSortKey() = default;
|
||||
constexpr TaskSourceSortKey(TaskPriority priority,
|
||||
TimeTicks ready_time,
|
||||
uint8_t worker_count = 0)
|
||||
: priority_(priority),
|
||||
worker_count_(worker_count),
|
||||
ready_time_(ready_time) {}
|
||||
|
||||
TaskPriority priority() const { return priority_; }
|
||||
uint8_t worker_count() const { return worker_count_; }
|
||||
|
@ -16,7 +16,7 @@ namespace base::internal {
|
||||
namespace {
|
||||
|
||||
// Keys are manually ordered from the least important to the most important.
|
||||
const auto kTestKeys = std::to_array<TaskSourceSortKey>({
|
||||
constexpr auto kTestKeys = std::to_array<TaskSourceSortKey>({
|
||||
{TaskPriority::BEST_EFFORT, TimeTicks() + Seconds(2000)},
|
||||
{TaskPriority::BEST_EFFORT, TimeTicks() + Seconds(1000)},
|
||||
{TaskPriority::USER_VISIBLE, TimeTicks() + Seconds(2000), 1},
|
||||
|
Reference in New Issue
Block a user