xref: /aosp_15_r20/external/cronet/base/task/thread_pool/pooled_parallel_task_runner.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2018 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef BASE_TASK_THREAD_POOL_POOLED_PARALLEL_TASK_RUNNER_H_
6 #define BASE_TASK_THREAD_POOL_POOLED_PARALLEL_TASK_RUNNER_H_
7 
8 #include "base/base_export.h"
9 #include "base/functional/callback_forward.h"
10 #include "base/location.h"
11 #include "base/memory/raw_ptr.h"
12 #include "base/task/task_runner.h"
13 #include "base/task/task_traits.h"
14 #include "base/time/time.h"
15 
16 namespace base {
17 namespace internal {
18 
19 class PooledTaskRunnerDelegate;
20 
21 // A task runner that runs tasks in parallel.
22 class BASE_EXPORT PooledParallelTaskRunner : public TaskRunner {
23  public:
24   // Constructs a PooledParallelTaskRunner which can be used to post tasks.
25   PooledParallelTaskRunner(
26       const TaskTraits& traits,
27       PooledTaskRunnerDelegate* pooled_task_runner_delegate);
28   PooledParallelTaskRunner(const PooledParallelTaskRunner&) = delete;
29   PooledParallelTaskRunner& operator=(const PooledParallelTaskRunner&) = delete;
30 
31   // TaskRunner:
32   bool PostDelayedTask(const Location& from_here,
33                        OnceClosure closure,
34                        TimeDelta delay) override;
35 
36  private:
37   ~PooledParallelTaskRunner() override;
38 
39   const TaskTraits traits_;
40   const raw_ptr<PooledTaskRunnerDelegate, DanglingUntriaged>
41       pooled_task_runner_delegate_;
42 };
43 
44 }  // namespace internal
45 }  // namespace base
46 
47 #endif  // BASE_TASK_THREAD_POOL_POOLED_PARALLEL_TASK_RUNNER_H_
48