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 "utils_timer.h"
17
18 #include "nativeapi_timer_task.h"
19 #include "ohos_types.h"
20
UtilsStartPeriodicTimerTask(uint32_t interval,TimerProc callback,const void * context)21 TimerHandle UtilsStartPeriodicTimerTask(uint32_t interval, TimerProc callback, const void *context)
22 {
23 timerHandle_t handle = NULL;
24 StartTimerTask(TRUE, interval, callback, context, &handle);
25 return (TimerHandle)handle;
26 }
27
UtilsStartOnceTimerTask(uint32_t interval,TimerProc callback,const void * context)28 TimerHandle UtilsStartOnceTimerTask(uint32_t interval, TimerProc callback, const void *context)
29 {
30 timerHandle_t handle = NULL;
31 StartTimerTask(FALSE, interval, callback, context, &handle);
32 return (TimerHandle)handle;
33 }
34
UtilsStopTimerTask(TimerHandle handle)35 void UtilsStopTimerTask(TimerHandle handle)
36 {
37 StopTimerTask((timerHandle_t)handle);
38 }