• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# timer.h
2
3<!--Kit: Function Flow Runtime Kit-->
4<!--Subsystem: Resourceschedule-->
5<!--Owner: @chuchihtung; @yanleo-->
6<!--Designer: @geoffrey_guo; @huangyouzhong-->
7<!--Tester: @lotsof; @sunxuhao-->
8<!--Adviser: @foryourself-->
9
10## Overview
11
12The **timer.h** file declares the timer APIs in C.
13
14**File to include**: <ffrt/timer.h>
15
16**Library**: libffrt.z.so
17
18**System capability**: SystemCapability.Resourceschedule.Ffrt.Core
19
20**Since**: 12
21
22**Related module**: [FFRT](capi-ffrt.md)
23
24## Summary
25
26### Function
27
28| Name| Description|
29| -- | -- |
30| [FFRT_C_API ffrt_timer_t ffrt_timer_start(ffrt_qos_t qos, uint64_t timeout, void* data, ffrt_timer_cb cb, bool repeat)](#ffrt_timer_start) | Starts the timer.|
31| [FFRT_C_API int ffrt_timer_stop(ffrt_qos_t qos, ffrt_timer_t handle)](#ffrt_timer_stop) | Stops the timer.|
32
33## Function Description
34
35### ffrt_timer_start()
36
37```
38FFRT_C_API ffrt_timer_t ffrt_timer_start(ffrt_qos_t qos, uint64_t timeout, void* data, ffrt_timer_cb cb, bool repeat)
39```
40
41**Description**
42
43Starts the timer.
44
45**Since**: 12
46
47
48**Parameters**
49
50| Name                                                 | Description|
51|------------------------------------------------------| -- |
52| [ffrt_qos_t](capi-type-def-h.md#variables) qos             | QoS.|
53| uint64_t timeout                                     | Timeout, in milliseconds.|
54| void* data                                           | Pointer to the input parameter in the callback function invoked upon a timeout.|
55| [ffrt_timer_cb](capi-type-def-h.md#ffrt_timer_cb) cb | Callback function invoked upon a timeout.|
56| bool repeat                                          | Whether to repeat the timer (not supported yet).|
57
58**Returns**
59
60| Type                         | Description|
61|-----------------------------| -- |
62| FFRT_C_API [ffrt_timer_t](capi-type-def-h.md#variables)| Returns the timer handle.|
63
64### ffrt_timer_stop()
65
66```
67FFRT_C_API int ffrt_timer_stop(ffrt_qos_t qos, ffrt_timer_t handle)
68```
69
70**Description**
71
72Stops the timer.
73
74**Since**: 12
75
76
77**Parameters**
78
79| Name| Description|
80| -- | -- |
81| ffrt_qos_t qos | QoS.|
82| ffrt_timer_t handle | Handle to the timer.|
83
84**Returns**
85
86| Type| Description|
87| -- | -- |
88| FFRT_C_API int | Returns **0** if the timer is stopped successfully;<br>          returns **-1** otherwise.|
89