1 /* 2 * Copyright (c) 2024 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 #ifndef RENDER_SERVICE_BASE_COMMON_RS_XCOLLIE_H 16 #define RENDER_SERVICE_BASE_COMMON_RS_XCOLLIE_H 17 18 #include <string> 19 #include "common/rs_common_def.h" 20 #include "common/rs_macros.h" 21 22 namespace OHOS { 23 namespace Rosen { 24 class RSB_EXPORT RSXCollie final { 25 public: 26 /* 27 * @brief monitor whether the execution time of the code segment exceeds expectations. 28 * @param tag rs timer name. 29 * @param timeoutSeconds Timeout duration(S), default 6s. 30 * @param func callback function. 31 * @param arg callback arg. 32 * @param flag default(1) to generate log, if you need more, see xcollie_define.h. 33 */ 34 RSXCollie(const std::string& tag, uint32_t timeoutSeconds = 6, 35 std::function<void(void*)> func = nullptr, void* arg = nullptr, uint32_t flag = 1); 36 ~RSXCollie(); 37 private: 38 void CancelRSXCollie(void); 39 int32_t id_ = -1; 40 bool isCanceled_ = false; 41 std::string tag_; 42 }; 43 } // namespace Rosen 44 } // namespace OHOS 45 #endif // RENDER_SERVICE_BASE_COMMON_RS_XCOLLIE_H 46