gcomputation_async.hpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. #ifndef OPENCV_GAPI_GCOMPUTATION_ASYNC_HPP
  7. #define OPENCV_GAPI_GCOMPUTATION_ASYNC_HPP
  8. #include <future> //for std::future
  9. #include <exception> //for std::exception_ptr
  10. #include <functional> //for std::function
  11. #include <opencv2/gapi/garg.hpp> //for GRunArgs, GRunArgsP
  12. #include <opencv2/gapi/gcommon.hpp> //for GCompileArgs
  13. #include <opencv2/gapi/own/exports.hpp>
  14. namespace cv {
  15. //fwd declaration
  16. class GComputation;
  17. namespace gapi {
  18. namespace wip {
  19. class GAsyncContext;
  20. /** In contrast to async() functions, these do call GComputation::apply() member function of the GComputation passed in.
  21. @param gcomp Computation (graph) to run asynchronously
  22. @param callback Callback to be called when execution of gcomp is done
  23. @param ins Input parameters for gcomp
  24. @param outs Output parameters for gcomp
  25. @param args Compile arguments to pass to GComputation::apply()
  26. @see async
  27. */
  28. GAPI_EXPORTS void async_apply(GComputation& gcomp, std::function<void(std::exception_ptr)>&& callback, GRunArgs &&ins, GRunArgsP &&outs, GCompileArgs &&args = {});
  29. /** @overload
  30. @param gcomp Computation (graph) to run asynchronously
  31. @param callback Callback to be called when execution of gcomp is done
  32. @param ins Input parameters for gcomp
  33. @param outs Output parameters for gcomp
  34. @param args Compile arguments to pass to GComputation::apply()
  35. @param ctx Context this request belongs to
  36. @see async_apply async GAsyncContext
  37. */
  38. GAPI_EXPORTS void async_apply(GComputation& gcomp, std::function<void(std::exception_ptr)>&& callback, GRunArgs &&ins, GRunArgsP &&outs, GCompileArgs &&args, GAsyncContext& ctx);
  39. /** @overload
  40. @param gcomp Computation (graph) to run asynchronously
  41. @param ins Input parameters for gcomp
  42. @param outs Output parameters for gcomp
  43. @param args Compile arguments to pass to GComputation::apply()
  44. @return std::future<void> object to wait for completion of async operation
  45. @see async_apply async
  46. */
  47. GAPI_EXPORTS std::future<void> async_apply(GComputation& gcomp, GRunArgs &&ins, GRunArgsP &&outs, GCompileArgs &&args = {});
  48. /** @overload
  49. @param gcomp Computation (graph) to run asynchronously
  50. @param ins Input parameters for gcomp
  51. @param outs Output parameters for gcomp
  52. @param args Compile arguments to pass to GComputation::apply()
  53. @param ctx Context this request belongs to
  54. @return std::future<void> object to wait for completion of async operation
  55. @see async_apply async GAsyncContext
  56. */
  57. GAPI_EXPORTS std::future<void> async_apply(GComputation& gcomp, GRunArgs &&ins, GRunArgsP &&outs, GCompileArgs &&args, GAsyncContext& ctx);
  58. } // namespace wip
  59. } // namespace gapi
  60. } // namespace cv
  61. #endif //OPENCV_GAPI_GCOMPUTATION_ASYNC_HPP