blob: 2cef39e931685caeccd8b22a4b6cc860b3c31541 [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/logging.h"
#include "base/macros.h"
#include "base/task/task_scheduler/task_tracker.h"
#include "base/threading/platform_thread.h"
namespace base {
namespace internal {
struct Task;
// A TaskTracker that instantiates a FileDescriptorWatcher in the scope in which
// a task runs. Used on all POSIX platforms except NaCl SFI.
// set_io_thread_task_runner() must be called before the
// TaskTracker can run tasks.
class BASE_EXPORT TaskTrackerPosix : public TaskTracker {
TaskTrackerPosix(StringPiece name);
~TaskTrackerPosix() override;
// Sets the task runner with which to setup FileDescriptorWatcher in
// the scope in which tasks run. |io_thread_task_runner| must refer to
// a Thread with MessageLoop::TYPE_IO.
// Must be called before starting to run tasks.
// External synchronization is required between a call to this and a call to
// RunTask().
void set_io_thread_task_runner(
scoped_refptr<SingleThreadTaskRunner> io_thread_task_runner) {
io_thread_task_runner_ = std::move(io_thread_task_runner);
// TaskTracker:
void RunOrSkipTask(Task task,
Sequence* sequence,
const TaskTraits& traits,
bool can_run_task) override;
scoped_refptr<SingleThreadTaskRunner> io_thread_task_runner_;
} // namespace internal
} // namespace base