github.com/kaydxh/golang@v0.0.131/pkg/gocv/cgo/third_path/opencv4/include/opencv2/gapi/gcompiled_async.hpp (about) 1 // This file is part of OpenCV project. 2 // It is subject to the license terms in the LICENSE file found in the top-level directory 3 // of this distribution and at http://opencv.org/license.html. 4 // 5 // Copyright (C) 2019 Intel Corporation 6 7 8 #ifndef OPENCV_GAPI_GCOMPILED_ASYNC_HPP 9 #define OPENCV_GAPI_GCOMPILED_ASYNC_HPP 10 11 #include <future> //for std::future 12 #include <exception> //for std::exception_ptr 13 #include <functional> //for std::function 14 #include <opencv2/gapi/garg.hpp> 15 #include <opencv2/gapi/own/exports.hpp> 16 17 namespace cv { 18 //fwd declaration 19 class GCompiled; 20 21 namespace gapi{ 22 namespace wip { 23 class GAsyncContext; 24 /** 25 These functions asynchronously (i.e. probably on a separate thread of execution) call GCompiled::operator() member function of their first argument with copies of rest of arguments (except callback) passed in. 26 The difference between the function is the way to get the completion notification (via callback or a waiting on std::future object) 27 If exception is occurred during execution of apply it is transferred to the callback (via function parameter) or passed to future (and will be thrown on call to std::future::get) 28 29 N.B. : 30 Input arguments are copied on call to async function (actually on call to cv::gin) and thus do not have to outlive the actual completion of asynchronous activity. 31 While output arguments are "captured" by reference(pointer) and therefore _must_ outlive the asynchronous activity 32 (i.e. live at least until callback is called or future is unblocked) 33 34 @param gcmpld Compiled computation (graph) to start asynchronously 35 @param callback Callback to be called when execution of gcmpld is done 36 @param ins Input parameters for gcmpld 37 @param outs Output parameters for gcmpld 38 */ 39 GAPI_EXPORTS void async(GCompiled& gcmpld, std::function<void(std::exception_ptr)>&& callback, GRunArgs &&ins, GRunArgsP &&outs); 40 41 /** @overload 42 @param gcmpld Compiled computation (graph) to run asynchronously 43 @param callback Callback to be called when execution of gcmpld is done 44 @param ins Input parameters for gcmpld 45 @param outs Output parameters for gcmpld 46 @param ctx Context this request belongs to 47 @see async GAsyncContext 48 */ 49 GAPI_EXPORTS void async(GCompiled& gcmpld, std::function<void(std::exception_ptr)>&& callback, GRunArgs &&ins, GRunArgsP &&outs, GAsyncContext& ctx); 50 51 /** @overload 52 @param gcmpld Compiled computation (graph) to run asynchronously 53 @param ins Input parameters for gcmpld 54 @param outs Output parameters for gcmpld 55 @return std::future<void> object to wait for completion of async operation 56 @see async 57 */ 58 GAPI_EXPORTS std::future<void> async(GCompiled& gcmpld, GRunArgs &&ins, GRunArgsP &&outs); 59 60 /** 61 @param gcmpld Compiled computation (graph) to run asynchronously 62 @param ins Input parameters for gcmpld 63 @param outs Output parameters for gcmpld 64 @param ctx Context this request belongs to 65 @return std::future<void> object to wait for completion of async operation 66 @see async GAsyncContext 67 */ 68 GAPI_EXPORTS std::future<void> async(GCompiled& gcmpld, GRunArgs &&ins, GRunArgsP &&outs, GAsyncContext& ctx); 69 } // namespace wip 70 } // namespace gapi 71 } // namespace cv 72 73 #endif // OPENCV_GAPI_GCOMPILED_ASYNC_HPP