1 /* 2 * Copyright (c) 2021 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 #ifndef I_EVENT_H 17 #define I_EVENT_H 18 19 #include <memory> 20 21 #include "utils/aie_macros.h" 22 23 namespace OHOS { 24 namespace AI { 25 class IEvent { 26 FORBID_COPY_AND_ASSIGN(IEvent); 27 FORBID_CREATE_BY_SELF(IEvent); 28 public: 29 /** 30 * Plugins prohibit the use of new, so add a create method here. 31 */ 32 static std::shared_ptr<IEvent> MakeShared(); 33 34 /** 35 * Wait for the event to wake up within the specified time. 36 * 37 * @param [in] milliSeconds Waiting time (ms). 38 * @return Whether it is awakened successfully or not within the specified time. 39 */ 40 bool Wait(const int milliSeconds = -1) const; 41 42 /** 43 * Wake up the thread waiting for the event. 44 * 45 * @return Whether the event is in reset state before wake-up. true: reset state, false: set state. 46 */ 47 bool Signal(); 48 49 /** 50 * Reset event flag to false. 51 * 52 * @return Event setting status before reset. 53 */ 54 bool Reset(); 55 56 /** 57 * Determine whether the event is set. 58 */ 59 bool IsSet() const; 60 }; 61 } // namespace AI 62 } // namespace OHOS 63 64 #endif // I_EVENT_H