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 
16 #include "task_manager.h"
17 namespace OHOS::DistributedData {
TaskManager(std::shared_ptr<ExecutorPool> executors)18 TaskManager::TaskManager(std::shared_ptr<ExecutorPool> executors) : executors_(executors)
19 {
20 }
21 
~TaskManager()22 TaskManager::~TaskManager()
23 {
24     executors_ = nullptr;
25 }
Execute(const Task & task)26 TaskManager::TaskId TaskManager::Execute(const Task &task)
27 {
28     return executors_->Execute(task);
29 }
Execute(const Task & task,Duration delay)30 TaskManager::TaskId TaskManager::Execute(const Task &task, Duration delay)
31 {
32     return executors_->Schedule(delay, task);
33 }
Schedule(const Task & task,Duration interval)34 TaskManager::TaskId TaskManager::Schedule(const Task &task, Duration interval)
35 {
36     return executors_->Schedule(task, interval);
37 }
Schedule(const Task & task,Duration delay,Duration interval)38 TaskManager::TaskId TaskManager::Schedule(const Task &task, Duration delay, Duration interval)
39 {
40     return executors_->Schedule(task, delay, interval);
41 }
Schedule(const Task & task,Duration delay,Duration interval,uint64_t times)42 TaskManager::TaskId TaskManager::Schedule(const Task &task, Duration delay, Duration interval, uint64_t times)
43 {
44     return executors_->Schedule(task, delay, interval, times);
45 }
Remove(const TaskId & taskId,bool wait)46 bool TaskManager::Remove(const TaskId &taskId, bool wait)
47 {
48     return executors_->Remove(taskId, wait);
49 }
Reset(const TaskId & taskId,Duration interval)50 TaskManager::TaskId TaskManager::Reset(const TaskId &taskId, Duration interval)
51 {
52     return executors_->Reset(taskId, interval);
53 }
54 } // namespace OHOS::DistributedData
55