blob: dc07eecdc710edcb1d2d126fb6c9d42b382545a6 [file] [log] [blame]
Avi Drissmane4622aa2022-09-08 20:36:061// Copyright 2012 The Chromium Authors
[email protected]6b28d942012-02-15 01:43:192// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Patrick Monette643cdf62021-10-15 19:13:425#include "base/task/task_runner.h"
[email protected]6b28d942012-02-15 01:43:196
tzik03527512017-02-08 12:29:477#include <utility>
8
Hans Wennborgc3cffa62020-04-27 10:09:129#include "base/check.h"
[email protected]6b28d942012-02-15 01:43:1910#include "base/compiler_specific.h"
Avi Drissman63e1f992023-01-13 18:54:4311#include "base/functional/bind.h"
Keishi Hattori0e45c022021-11-27 09:25:5212#include "base/memory/raw_ptr.h"
[email protected]6b28d942012-02-15 01:43:1913#include "base/threading/post_task_and_reply_impl.h"
David Sanders2799ee22022-02-03 05:01:4814#include "base/time/time.h"
[email protected]6b28d942012-02-15 01:43:1915
16namespace base {
17
Brett Wilson8e88b312017-09-12 05:22:1618bool TaskRunner::PostTask(const Location& from_here, OnceClosure task) {
tzik070c8ffb2017-03-29 05:28:1219 return PostDelayedTask(from_here, std::move(task), base::TimeDelta());
[email protected]6b28d942012-02-15 01:43:1920}
21
Brett Wilson8e88b312017-09-12 05:22:1622bool TaskRunner::PostTaskAndReply(const Location& from_here,
tzik6e427842017-04-05 10:13:2123 OnceClosure task,
24 OnceClosure reply) {
Daniel Cheng099aa052023-08-21 21:57:5425 return internal::PostTaskAndReplyImpl(
26 [this](const Location& location, OnceClosure task) {
27 return PostTask(location, std::move(task));
28 },
tzik03527512017-02-08 12:29:4729 from_here, std::move(task), std::move(reply));
[email protected]6b28d942012-02-15 01:43:1930}
31
Chris Watkinsbb7211c2017-11-29 07:16:3832TaskRunner::TaskRunner() = default;
[email protected]6b28d942012-02-15 01:43:1933
Chris Watkinsbb7211c2017-11-29 07:16:3834TaskRunner::~TaskRunner() = default;
[email protected]6b28d942012-02-15 01:43:1935
36void TaskRunner::OnDestruct() const {
37 delete this;
38}
39
40void TaskRunnerTraits::Destruct(const TaskRunner* task_runner) {
41 task_runner->OnDestruct();
42}
43
44} // namespace base