Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: add an ability to use c++ 11 lambda expression as a parallel_for_ body #9017

Merged
merged 2 commits into from
Jun 29, 2017

Conversation

sovrasov
Copy link
Contributor

@sovrasov sovrasov commented Jun 28, 2017

No description provided.

@sovrasov sovrasov added this to the 3.3-rc milestone Jun 28, 2017
@@ -455,6 +455,29 @@ void cv::parallel_for_(const cv::Range& range, const cv::ParallelLoopBody& body,
}
}

#if __cplusplus >= 201103L
class ParallelLoopBodyLambdaWrapper : public cv::ParallelLoopBody
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we can put this into header files (without requirement for new CV_EXPORTS functions)

Copy link
Contributor Author

@sovrasov sovrasov Jun 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But in this case user should use strange wrapper instead of directly pass lambda to parallel_for_. Most users can write such a dummy wrapper by themselves, so we don't need this PR at all.
@vpisarev what do you think?
upd: I've understood the idea.

@@ -56,6 +56,10 @@
#include "opencv2/core.hpp"
#include <ostream>

#if __cplusplus >= 201103L
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MSVC defines __cplusplus to 199711
Probably we should target for MSVS 2013+ too.
Check this condition.

Copy link
Contributor Author

@sovrasov sovrasov Jun 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be we should replace separate c++ 11 features detection with common CV_CXX11 in cvdef.h

@mshabunin mshabunin modified the milestones: 3.3, 3.3-rc Jun 28, 2017
@sovrasov sovrasov force-pushed the parallel_for_cxx11 branch 2 times, most recently from 7bbfe7b to 6730831 Compare June 28, 2017 13:08
@@ -56,6 +56,10 @@
#include "opencv2/core.hpp"
#include <ostream>

#if CV_CXX_11
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#ifdef should be used here with current macro implementation.

@vpisarev
Copy link
Contributor

looks cool! 👍

@opencv-pushbot opencv-pushbot merged commit 08db55f into opencv:master Jun 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants