1 /*
2 * Copyright (c) 2021-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 "watchdog.h"
17
18 #include "watchdog_inner.h"
19
20 namespace OHOS {
21 namespace HiviewDFX {
Watchdog()22 Watchdog::Watchdog()
23 {
24 }
25
~Watchdog()26 Watchdog::~Watchdog()
27 {
28 }
29
AddThread(const std::string & name,std::shared_ptr<AppExecFwk::EventHandler> handler,TimeOutCallback timeOutCallback,uint64_t interval)30 int Watchdog::AddThread(const std::string &name, std::shared_ptr<AppExecFwk::EventHandler> handler,
31 TimeOutCallback timeOutCallback, uint64_t interval)
32 {
33 return WatchdogInner::GetInstance().AddThread(name, handler, timeOutCallback, interval);
34 }
35
AddThread(const std::string & name,std::shared_ptr<AppExecFwk::EventHandler> handler,uint64_t interval)36 int Watchdog::AddThread(const std::string &name, std::shared_ptr<AppExecFwk::EventHandler> handler, uint64_t interval)
37 {
38 return WatchdogInner::GetInstance().AddThread(name, handler, nullptr, interval);
39 }
40
RunOneShotTask(const std::string & name,Task && task,uint64_t delay)41 void Watchdog::RunOneShotTask(const std::string& name, Task&& task, uint64_t delay)
42 {
43 return WatchdogInner::GetInstance().RunOneShotTask(name, std::move(task), delay);
44 }
45
RunPeriodicalTask(const std::string & name,Task && task,uint64_t interval,uint64_t delay)46 void Watchdog::RunPeriodicalTask(const std::string& name, Task&& task, uint64_t interval, uint64_t delay)
47 {
48 return WatchdogInner::GetInstance().RunPeriodicalTask(name, std::move(task), interval, delay);
49 }
50
StopWatchdog()51 void Watchdog::StopWatchdog()
52 {
53 return WatchdogInner::GetInstance().StopWatchdog();
54 }
55
InitFfrtWatchdog()56 void Watchdog::InitFfrtWatchdog()
57 {
58 return WatchdogInner::GetInstance().InitFfrtWatchdog();
59 }
60 } // end of namespace HiviewDFX
61 } // end of namespace OHOS
62