[email protected] | 2837654 | 2011-10-14 17:30:37 | [diff] [blame] | 1 | // 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 Doray | f3d1fac | 2017-09-27 16:59:40 | [diff] [blame] | 5 | // This file contains the implementation for TaskRunner::PostTaskAndReply. |
[email protected] | 2837654 | 2011-10-14 17:30:37 | [diff] [blame] | 6 | |
7 | #ifndef BASE_THREADING_POST_TASK_AND_REPLY_IMPL_H_ | ||||
8 | #define BASE_THREADING_POST_TASK_AND_REPLY_IMPL_H_ | ||||
[email protected] | 2837654 | 2011-10-14 17:30:37 | [diff] [blame] | 9 | |
fdoray | 2b295de | 2016-07-29 22:49:49 | [diff] [blame] | 10 | #include "base/base_export.h" |
tzik | 0352751 | 2017-02-08 12:29:47 | [diff] [blame] | 11 | #include "base/callback.h" |
[email protected] | 2837654 | 2011-10-14 17:30:37 | [diff] [blame] | 12 | #include "base/location.h" |
13 | |||||
14 | namespace base { | ||||
15 | namespace internal { | ||||
16 | |||||
fdoray | 2b295de | 2016-07-29 22:49:49 | [diff] [blame] | 17 | // Inherit from this in a class that implements PostTask to send a task to a |
18 | // custom execution context. | ||||
[email protected] | 2837654 | 2011-10-14 17:30:37 | [diff] [blame] | 19 | // |
fdoray | 2b295de | 2016-07-29 22:49:49 | [diff] [blame] | 20 | // If you're looking for a concrete implementation of PostTaskAndReply, you |
Francois Doray | f3d1fac | 2017-09-27 16:59:40 | [diff] [blame] | 21 | // probably want base::TaskRunner. |
22 | // | ||||
23 | // TODO(fdoray): Move this to the anonymous namespace of base/task_runner.cc. | ||||
fdoray | 2b295de | 2016-07-29 22:49:49 | [diff] [blame] | 24 | class BASE_EXPORT PostTaskAndReplyImpl { |
[email protected] | 2837654 | 2011-10-14 17:30:37 | [diff] [blame] | 25 | public: |
derat | 99c5d9fb | 2015-07-13 15:22:24 | [diff] [blame] | 26 | virtual ~PostTaskAndReplyImpl() = default; |
27 | |||||
fdoray | 2b295de | 2016-07-29 22:49:49 | [diff] [blame] | 28 | // 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 Wilson | 8e88b31 | 2017-09-12 05:22:16 | [diff] [blame] | 32 | bool PostTaskAndReply(const Location& from_here, |
tzik | 6e42784 | 2017-04-05 10:13:21 | [diff] [blame] | 33 | OnceClosure task, |
34 | OnceClosure reply); | ||||
[email protected] | 2837654 | 2011-10-14 17:30:37 | [diff] [blame] | 35 | |
36 | private: | ||||
Brett Wilson | 8e88b31 | 2017-09-12 05:22:16 | [diff] [blame] | 37 | virtual bool PostTask(const Location& from_here, OnceClosure task) = 0; |
[email protected] | 2837654 | 2011-10-14 17:30:37 | [diff] [blame] | 38 | }; |
39 | |||||
40 | } // namespace internal | ||||
41 | } // namespace base | ||||
42 | |||||
43 | #endif // BASE_THREADING_POST_TASK_AND_REPLY_IMPL_H_ |