1 /* 2 * Copyright (c) 2023 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 /** 17 * @addtogroup FFRT 18 * @{ 19 * 20 * @brief Provides FFRT C APIs. 21 * 22 * @since 10 23 */ 24 25 /** 26 * @file sleep.h 27 * 28 * @brief Declares the sleep and yield interfaces in C. 29 * 30 * @library libffrt.z.so 31 * @kit FunctionFlowRuntimeKit 32 * @syscap SystemCapability.Resourceschedule.Ffrt.Core 33 * @since 10 34 */ 35 36 #ifndef FFRT_API_C_SLEEP_H 37 #define FFRT_API_C_SLEEP_H 38 39 #include <stdint.h> 40 #include "type_def.h" 41 42 /** 43 * @brief Suspends the calling thread for a given duration. 44 * 45 * @param usec Indicates the duration that the calling thread is suspended, in microseconds. 46 * @return Returns <b>ffrt_success</b> if the thread is suspended; 47 returns <b>ffrt_error</b> otherwise. 48 * @since 10 49 */ 50 FFRT_C_API int ffrt_usleep(uint64_t usec); 51 52 /** 53 * @brief Passes control to other tasks so that they can be executed. 54 * 55 * @since 10 56 */ 57 FFRT_C_API void ffrt_yield(void); 58 59 #endif // FFRT_API_C_SLEEP_H 60 /** @} */