blob: 696a655db0bddc6cdae6f8333c15b71a391681f3 [file] [log] [blame]
[email protected]28376542011-10-14 17:30:371// Copyright (c) 2011 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Francois Dorayf3d1fac2017-09-27 16:59:405// This file contains the implementation for TaskRunner::PostTaskAndReply.
[email protected]28376542011-10-14 17:30:376
7#ifndef BASE_THREADING_POST_TASK_AND_REPLY_IMPL_H_
8#define BASE_THREADING_POST_TASK_AND_REPLY_IMPL_H_
[email protected]28376542011-10-14 17:30:379
fdoray2b295de2016-07-29 22:49:4910#include "base/base_export.h"
tzik03527512017-02-08 12:29:4711#include "base/callback.h"
[email protected]28376542011-10-14 17:30:3712#include "base/location.h"
13
14namespace base {
15namespace internal {
16
fdoray2b295de2016-07-29 22:49:4917// Inherit from this in a class that implements PostTask to send a task to a
18// custom execution context.
[email protected]28376542011-10-14 17:30:3719//
fdoray2b295de2016-07-29 22:49:4920// If you're looking for a concrete implementation of PostTaskAndReply, you
Francois Dorayf3d1fac2017-09-27 16:59:4021// probably want base::TaskRunner.
22//
23// TODO(fdoray): Move this to the anonymous namespace of base/task_runner.cc.
fdoray2b295de2016-07-29 22:49:4924class BASE_EXPORT PostTaskAndReplyImpl {
[email protected]28376542011-10-14 17:30:3725 public:
derat99c5d9fb2015-07-13 15:22:2426 virtual ~PostTaskAndReplyImpl() = default;
27
fdoray2b295de2016-07-29 22:49:4928 // Posts |task| by calling PostTask(). On completion, |reply| is posted to the
29 // sequence or thread that called this. Can only be called when
30 // SequencedTaskRunnerHandle::IsSet(). Both |task| and |reply| are guaranteed
31 // to be deleted on the sequence or thread that called this.
Brett Wilson8e88b312017-09-12 05:22:1632 bool PostTaskAndReply(const Location& from_here,
tzik6e427842017-04-05 10:13:2133 OnceClosure task,
34 OnceClosure reply);
[email protected]28376542011-10-14 17:30:3735
36 private:
Brett Wilson8e88b312017-09-12 05:22:1637 virtual bool PostTask(const Location& from_here, OnceClosure task) = 0;
[email protected]28376542011-10-14 17:30:3738};
39
40} // namespace internal
41} // namespace base
42
43#endif // BASE_THREADING_POST_TASK_AND_REPLY_IMPL_H_