From 74b6646737662ba848ea39f2d69fafc19145b022 Mon Sep 17 00:00:00 2001 From: Anton Potapov Date: Mon, 30 Nov 2020 09:40:42 +0300 Subject: [PATCH] GAPI: reuse copy_through_move_t in the gasync.cpp file --- modules/gapi/src/executor/gasync.cpp | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/modules/gapi/src/executor/gasync.cpp b/modules/gapi/src/executor/gasync.cpp index b92dbdcec4..902e6e1624 100644 --- a/modules/gapi/src/executor/gasync.cpp +++ b/modules/gapi/src/executor/gasync.cpp @@ -11,6 +11,8 @@ #include #include +#include + #include #include @@ -18,16 +20,6 @@ #include #include -namespace { - //This is a tool to move initialize captures of a lambda in C++11 - template - struct copy_through_move{ - T value; - copy_through_move(T&& g) : value(std::move(g)) {} - copy_through_move(copy_through_move&&) = default; - copy_through_move(copy_through_move const& lhs) : copy_through_move(std::move(const_cast(lhs))) {} - }; -} namespace cv { namespace gapi { @@ -168,7 +160,7 @@ const char* GAsyncCanceled::what() const noexcept { //For now these async functions are simply wrapping serial version of apply/operator() into a functor. //These functors are then serialized into single queue, which is processed by a devoted background thread. void async_apply(GComputation& gcomp, std::function&& callback, GRunArgs &&ins, GRunArgsP &&outs, GCompileArgs &&args){ - //TODO: use copy_through_move for all args except gcomp + //TODO: use copy_through_move_t for all args except gcomp //TODO: avoid code duplication between versions of "async" functions auto l = [=]() mutable { auto apply_l = [&](){ @@ -181,7 +173,7 @@ void async_apply(GComputation& gcomp, std::function&& } std::future async_apply(GComputation& gcomp, GRunArgs &&ins, GRunArgsP &&outs, GCompileArgs &&args){ - copy_through_move> prms{{}}; + util::copy_through_move_t> prms{{}}; auto f = prms.value.get_future(); auto l = [=]() mutable { auto apply_l = [&](){ @@ -196,7 +188,7 @@ std::future async_apply(GComputation& gcomp, GRunArgs &&ins, GRunArgsP &&o } void async_apply(GComputation& gcomp, std::function&& callback, GRunArgs &&ins, GRunArgsP &&outs, GCompileArgs &&args, GAsyncContext& ctx){ - //TODO: use copy_through_move for all args except gcomp + //TODO: use copy_through_move_t for all args except gcomp auto l = [=, &ctx]() mutable { auto apply_l = [&](){ gcomp.apply(std::move(ins), std::move(outs), std::move(args)); @@ -208,7 +200,7 @@ void async_apply(GComputation& gcomp, std::function&& } std::future async_apply(GComputation& gcomp, GRunArgs &&ins, GRunArgsP &&outs, GCompileArgs &&args, GAsyncContext& ctx){ - copy_through_move> prms{{}}; + util::copy_through_move_t> prms{{}}; auto f = prms.value.get_future(); auto l = [=, &ctx]() mutable { auto apply_l = [&](){ @@ -248,7 +240,7 @@ void async(GCompiled& gcmpld, std::function&& callback } std::future async(GCompiled& gcmpld, GRunArgs &&ins, GRunArgsP &&outs){ - copy_through_move> prms{{}}; + util::copy_through_move_t> prms{{}}; auto f = prms.value.get_future(); auto l = [=]() mutable { auto apply_l = [&](){ @@ -263,7 +255,7 @@ std::future async(GCompiled& gcmpld, GRunArgs &&ins, GRunArgsP &&outs){ } std::future async(GCompiled& gcmpld, GRunArgs &&ins, GRunArgsP &&outs, GAsyncContext& ctx){ - copy_through_move> prms{{}}; + util::copy_through_move_t> prms{{}}; auto f = prms.value.get_future(); auto l = [=, &ctx]() mutable { auto apply_l = [&](){