blob: d2cc9eef097beb86cb2f62db10231988e19cf2a5 [file] [log] [blame]
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <memory>
#include "base/base_export.h"
#include "base/macros.h"
namespace base {
namespace internal {
class DelayedTaskManager;
class SchedulerWorkerThread;
class TaskTracker;
// A thread dedicated to performing Task Scheduler related work.
class BASE_EXPORT SchedulerServiceThread {
// Creates a SchedulerServiceThread. |task_tracker| and |delayed_task_manager|
// are passed through to the underlying SchedulerWorkerThread. Returns a
// nullptr on failure.
static std::unique_ptr<SchedulerServiceThread> Create(
TaskTracker* task_tracker, DelayedTaskManager* delayed_task_manager);
// Wakes the SchedulerServiceThread if it wasn't already awake. This also has
// the impact of updating the amount of time the thread sleeps for delayed
// tasks.
void WakeUp();
// Joins this SchedulerServiceThread. This can only be called once.
void JoinForTesting();
SchedulerServiceThread(std::unique_ptr<SchedulerWorkerThread> worker_thread);
const std::unique_ptr<SchedulerWorkerThread> worker_thread_;
} // namespace internal
} // namespace base