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 #ifndef SOFTBUS_ADAPTER_XCOLLIE_H
17 #define SOFTBUS_ADAPTER_XCOLLIE_H
18 
19 #include <stdint.h>
20 
21 #ifdef __cplusplus
22 #if __cplusplus
23 extern "C" {
24 #endif
25 #endif
26 
27 /**
28 * @brief Called when set timer for service watchdog.
29 * @param name Indicates the point to the name of the timer.
30 * @param timeout Indicates the timeout.
31 * @param func Indicates the point to the callback function.
32 * @param args Indicates the point to the timer timeout operation.
33 *
34 * @return Return the timer id.
35 *
36 * @since 1.0
37 * @version 1.0
38 */
39 int32_t SoftBusSetWatchdogTimer(const char *name, uint32_t timeout, void(*func)(void*), void *args);
40 
41 /**
42 * @brief Called when cancel timer of service watchdog.
43 * @param id Indicates the id of the timer.
44 *
45 * @since 1.0
46 * @version 1.0
47 */
48 void SoftBusCancelWatchdogTimer(int32_t id);
49 
50 /**
51 * @brief Called when run a onshot task in shared watchdog thread, the submitted task should never be time consuming.
52 * @param name Indicates the point to the name of the task.
53 * @param task Indicates the point to a short function name.
54 * @param delay Indicates delay a few millisecond to run the task.
55 *
56 * @since 1.0
57 * @version 1.0
58 */
59 void SoftBusRunOneShotTask(const char *name, void(*task)(void), uint64_t delay);
60 
61 /**
62 * @brief Called when run a periodical task in shared watchdog thread.
63 * @param name Indicates the point to the name of the task.
64 * @param task Indicates the point to a short function name.
65 * @param interval Indicates the millisecond interval of the periodical task.
66 * @param delay Indicates delay a few millisecond to first run the task.
67 *
68 * @since 1.0
69 * @version 1.0
70 */
71 void SoftBusRunPeriodicalTask(const char *name, void(*task)(void), uint64_t interval, uint64_t delay);
72 
73 #ifdef __cplusplus
74 #if __cplusplus
75 }
76 #endif /* __cplusplus */
77 #endif /* __cplusplus */
78 
79 #endif // SOFTBUS_ADAPTER_XCOLLIE_H
80