Merge pull request #14689 from anton-potapov:gapi_async_cacnel
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
//
|
||||
// Copyright (C) 2019 Intel Corporation
|
||||
|
||||
#ifndef OPENCV_GAPI_GASYNC_CONTEXT_HPP
|
||||
#define OPENCV_GAPI_GASYNC_CONTEXT_HPP
|
||||
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
# include <opencv2/core/cvdef.h>
|
||||
#else // Without OpenCV
|
||||
# include <opencv2/gapi/own/cvdefs.hpp>
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
|
||||
#include <opencv2/gapi/own/exports.hpp>
|
||||
|
||||
namespace cv {
|
||||
namespace gapi{
|
||||
namespace wip {
|
||||
|
||||
class GAPI_EXPORTS GAsyncContext{
|
||||
std::atomic<bool> cancelation_requested = {false};
|
||||
public:
|
||||
//returns true if it was a first request to cancel the context
|
||||
bool cancel();
|
||||
bool isCanceled() const;
|
||||
};
|
||||
|
||||
class GAPI_EXPORTS GAsyncCanceled : public std::exception {
|
||||
public:
|
||||
virtual const char* what() const noexcept CV_OVERRIDE;
|
||||
};
|
||||
} // namespace wip
|
||||
} // namespace gapi
|
||||
} // namespace cv
|
||||
|
||||
#endif //OPENCV_GAPI_GASYNC_CONTEXT_HPP
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <exception> //for std::exception_ptr
|
||||
#include <functional> //for std::function
|
||||
#include <opencv2/gapi/garg.hpp>
|
||||
#include <opencv2/gapi/own/exports.hpp>
|
||||
|
||||
namespace cv {
|
||||
//fwd declaration
|
||||
@@ -19,13 +20,17 @@ namespace cv {
|
||||
|
||||
namespace gapi{
|
||||
namespace wip {
|
||||
class GAsyncContext;
|
||||
//These functions asynchronously (i.e. probably on a separate thread of execution) call operator() member function of their first argument with copies of rest of arguments (except callback) passed in.
|
||||
//The difference between the function is the way to get the completion notification (via callback or a waiting on std::future object)
|
||||
//If exception is occurred during execution of apply it is transfered to the callback (via function parameter) or passed to future (and will be thrown on call to std::future::get)
|
||||
GAPI_EXPORTS void async(GCompiled& gcmpld, std::function<void(std::exception_ptr)>&& callback, GRunArgs &&ins, GRunArgsP &&outs);
|
||||
GAPI_EXPORTS void async(GCompiled& gcmpld, std::function<void(std::exception_ptr)>&& callback, GRunArgs &&ins, GRunArgsP &&outs, GAsyncContext& ctx);
|
||||
|
||||
GAPI_EXPORTS std::future<void> async(GCompiled& gcmpld, GRunArgs &&ins, GRunArgsP &&outs);
|
||||
} // namespace gapi
|
||||
GAPI_EXPORTS std::future<void> async(GCompiled& gcmpld, GRunArgs &&ins, GRunArgsP &&outs, GAsyncContext& ctx);
|
||||
} // namespace wip
|
||||
} // namespace gapi
|
||||
} // namespace cv
|
||||
|
||||
#endif // OPENCV_GAPI_GCOMPILED_ASYNC_HPP
|
||||
|
||||
@@ -8,24 +8,30 @@
|
||||
#define OPENCV_GAPI_GCOMPUTATION_ASYNC_HPP
|
||||
|
||||
|
||||
#include <future>
|
||||
#include <future> //for std::future
|
||||
#include <exception> //for std::exception_ptr
|
||||
#include <functional> //for std::function
|
||||
#include <opencv2/gapi/garg.hpp> //for GRunArgs, GRunArgsP
|
||||
#include <opencv2/gapi/gcommon.hpp> //for GCompileArgs
|
||||
#include <opencv2/gapi/own/exports.hpp>
|
||||
|
||||
|
||||
namespace cv {
|
||||
//fwd declaration
|
||||
class GComputation;
|
||||
namespace gapi {
|
||||
namespace wip {
|
||||
class GAsyncContext;
|
||||
//These functions asynchronously (i.e. probably on a separate thread of execution) call apply member function of their first argument with copies of rest of arguments (except callback) passed in.
|
||||
//The difference between the function is the way to get the completion notification (via callback or a waiting on std::future object)
|
||||
//If exception is occurred during execution of apply it is transfered to the callback (via function parameter) or passed to future (and will be thrown on call to std::future::get)
|
||||
GAPI_EXPORTS void async_apply(GComputation& gcomp, std::function<void(std::exception_ptr)>&& callback, GRunArgs &&ins, GRunArgsP &&outs, GCompileArgs &&args = {});
|
||||
GAPI_EXPORTS void async_apply(GComputation& gcomp, std::function<void(std::exception_ptr)>&& callback, GRunArgs &&ins, GRunArgsP &&outs, GCompileArgs &&args, GAsyncContext& ctx);
|
||||
|
||||
GAPI_EXPORTS std::future<void> async_apply(GComputation& gcomp, GRunArgs &&ins, GRunArgsP &&outs, GCompileArgs &&args = {});
|
||||
} // nmaepspace gapi
|
||||
GAPI_EXPORTS std::future<void> async_apply(GComputation& gcomp, GRunArgs &&ins, GRunArgsP &&outs, GCompileArgs &&args, GAsyncContext& ctx);
|
||||
} // namespace wip
|
||||
} // namespace gapi
|
||||
} // namespace cv
|
||||
|
||||
|
||||
|
||||
@@ -108,6 +108,10 @@ typedef unsigned short ushort;
|
||||
#define CV_ELEM_SIZE(type) \
|
||||
(CV_MAT_CN(type) << ((((sizeof(size_t)/4+1)*16384|0x3a50) >> CV_MAT_DEPTH(type)*2) & 3))
|
||||
|
||||
#ifndef CV_OVERRIDE
|
||||
# define CV_OVERRIDE override
|
||||
#endif
|
||||
|
||||
// base.h:
|
||||
namespace cv
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user