17777dab0Sopenharmony_ci/*
27777dab0Sopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd.
37777dab0Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
47777dab0Sopenharmony_ci * you may not use this file except in compliance with the License.
57777dab0Sopenharmony_ci * You may obtain a copy of the License at
67777dab0Sopenharmony_ci *
77777dab0Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
87777dab0Sopenharmony_ci *
97777dab0Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
107777dab0Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
117777dab0Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
127777dab0Sopenharmony_ci * See the License for the specific language governing permissions and
137777dab0Sopenharmony_ci * limitations under the License.
147777dab0Sopenharmony_ci */
157777dab0Sopenharmony_ci
167777dab0Sopenharmony_ci/**
177777dab0Sopenharmony_ci * @addtogroup Ffrt
187777dab0Sopenharmony_ci * @{
197777dab0Sopenharmony_ci *
207777dab0Sopenharmony_ci * @brief ffrt provides APIs.
217777dab0Sopenharmony_ci *
227777dab0Sopenharmony_ci *
237777dab0Sopenharmony_ci * @syscap SystemCapability.Resourceschedule.Ffrt.Core
247777dab0Sopenharmony_ci *
257777dab0Sopenharmony_ci * @since 12
267777dab0Sopenharmony_ci */
277777dab0Sopenharmony_ci
287777dab0Sopenharmony_ci /**
297777dab0Sopenharmony_ci * @file timer.h
307777dab0Sopenharmony_ci * @kit FunctionFlowRuntimeKit
317777dab0Sopenharmony_ci *
327777dab0Sopenharmony_ci * @brief Declares the timer interfaces in C.
337777dab0Sopenharmony_ci *
347777dab0Sopenharmony_ci * @syscap SystemCapability.Resourceschedule.Ffrt.Core
357777dab0Sopenharmony_ci * @since 12
367777dab0Sopenharmony_ci * @version 1.0
377777dab0Sopenharmony_ci */
387777dab0Sopenharmony_ci#ifndef FFRT_API_C_TIMER_H
397777dab0Sopenharmony_ci#define FFRT_API_C_TIMER_H
407777dab0Sopenharmony_ci#include <stdbool.h>
417777dab0Sopenharmony_ci
427777dab0Sopenharmony_ci#include "type_def.h"
437777dab0Sopenharmony_ci
447777dab0Sopenharmony_ci/**
457777dab0Sopenharmony_ci * @brief Start a timer on ffrt worker
467777dab0Sopenharmony_ci *
477777dab0Sopenharmony_ci * @param qos Indicates qos of the worker that runs timer.
487777dab0Sopenharmony_ci * @param timeout Indicates the number of milliseconds that specifies timeout.
497777dab0Sopenharmony_ci * @param data Indicates user data used in cb.
507777dab0Sopenharmony_ci * @param cb Indicates user cb which will be executed when timeout.
517777dab0Sopenharmony_ci * @param repeat Indicates whether to repeat this timer.
527777dab0Sopenharmony_ci * @return Returns a timer handle.
537777dab0Sopenharmony_ci * @since 12
547777dab0Sopenharmony_ci * @version 1.0
557777dab0Sopenharmony_ci */
567777dab0Sopenharmony_ciFFRT_C_API ffrt_timer_t ffrt_timer_start(ffrt_qos_t qos, uint64_t timeout, void* data, ffrt_timer_cb cb, bool repeat);
577777dab0Sopenharmony_ci
587777dab0Sopenharmony_ci/**
597777dab0Sopenharmony_ci * @brief Stop a target timer on ffrt worker
607777dab0Sopenharmony_ci *
617777dab0Sopenharmony_ci * @param qos Indicates qos of the worker that runs timer.
627777dab0Sopenharmony_ci * @param handle Indicates the target timer handle.
637777dab0Sopenharmony_ci * @return Returns 0 if success;
647777dab0Sopenharmony_ci           returns -1 otherwise.
657777dab0Sopenharmony_ci * @since 12
667777dab0Sopenharmony_ci * @version 1.0
677777dab0Sopenharmony_ci */
687777dab0Sopenharmony_ciFFRT_C_API int ffrt_timer_stop(ffrt_qos_t qos, ffrt_timer_t handle);
697777dab0Sopenharmony_ci#endif