• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 #ifndef TASK_EXECUTOR_ADAPTER_H
16 #define TASK_EXECUTOR_ADAPTER_H
17 #include "ithread_pool.h"
18 #include "task_executor.h"
19 #include "visibility.h"
20 namespace OHOS::DistributedKv {
21 class TaskExecutorAdapter : public DistributedDB::IThreadPool {
22 public:
23     using TaskId = DistributedDB::TaskId;
24     using Task = std::function<void()>;
25     using Duration = std::chrono::steady_clock::duration;
26     TaskExecutorAdapter();
27     ~TaskExecutorAdapter() override;
28     TaskId Execute(const Task &task) override;
29     TaskId Execute(const Task &task, Duration delay) override;
30     TaskId Schedule(const Task &task, Duration interval) override;
31     TaskId Schedule(const Task &task, Duration delay, Duration interval) override;
32     TaskId Schedule(const Task &task, Duration delay, Duration interval, uint64_t times) override;
33     bool Remove(const TaskId &taskId, bool wait) override;
34     TaskId Reset(const TaskId &taskId, Duration interval) override;
35 };
36 } // namespace OHOS::DistributedKv
37 #endif // TASK_EXECUTOR_ADAPTER_H
38