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## 概述 11 12声明定时器的C接口。 13 14**引用文件:** <ffrt/timer.h> 15 16**库:** libffrt.z.so 17 18**系统能力:** SystemCapability.Resourceschedule.Ffrt.Core 19 20**起始版本:** 12 21 22**相关模块:** [FFRT](capi-ffrt.md) 23 24## 汇总 25 26### 函数 27 28| 名称 | 描述 | 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) | 启动计时器。 | 31| [FFRT_C_API int ffrt_timer_stop(ffrt_qos_t qos, ffrt_timer_t handle)](#ffrt_timer_stop) | 关闭计时器。 | 32 33## 函数说明 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**描述** 42 43启动计时器。 44 45**起始版本:** 12 46 47 48**参数:** 49 50| 参数项 | 描述 | 51| -- | -- | 52| [ffrt_qos_t](capi-type-def-h.md#变量) qos | QoS等级。 | 53| uint64_t timeout | 超时时间(毫秒)。 | 54| void* data | 超时后回调函数的入参。 | 55| [ffrt_timer_cb](capi-type-def-h.md#ffrt_timer_cb) cb | 超时执行的回调函数。 | 56| bool repeat | 是否重复执行该定时器(该功能暂未支持)。 | 57 58**返回:** 59 60| 类型 | 说明 | 61| -- | -- | 62| FFRT_C_API [ffrt_timer_t](capi-type-def-h.md#变量) | 返回定时器句柄。 | 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**描述** 71 72关闭计时器。 73 74**起始版本:** 12 75 76 77**参数:** 78 79| 参数项 | 描述 | 80| -- | -- | 81| ffrt_qos_t qos | QoS等级。 | 82| ffrt_timer_t handle | 定时器句柄。 | 83 84**返回:** 85 86| 类型 | 说明 | 87| -- | -- | 88| FFRT_C_API int | 关闭成功返回0,<br> 关闭失败返回-1。 | 89 90 91