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_FUTURE_H 17 #define I_FUTURE_H 18 19 #include "protocol/data_channel/include/i_request.h" 20 #include "protocol/data_channel/include/i_response.h" 21 22 namespace OHOS { 23 namespace AI { 24 enum FutureStatus { 25 FUTURE_OK, 26 FUTURE_ERROR, 27 }; 28 29 class IFuture { 30 public: 31 virtual ~IFuture() = default; 32 33 /** 34 * Get response some time later. 35 * 36 * @param [in] timeOut Delayed time, measured by millisecond. 37 * @return Return response pointer. 38 */ 39 virtual IResponse *GetResponse(int timeOut) const = 0; 40 41 /** 42 * Release resources. 43 */ 44 virtual void Release() = 0; 45 46 /** 47 * Get future status for async execution response. 48 * 49 * @return Returns FUTURE_OK if the operation is successful, returns FUTURE_ERROR otherwise. 50 */ 51 virtual FutureStatus Status() const = 0; 52 }; 53 } // namespace AI 54 } // namespace OHOS 55 56 #endif // I_FUTURE_H