Skip to content

imgproc: use C++11 std::atomic in color_hsv.simd.hpp #22050

New issue

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

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

Already on GitHub? # to your account

Closed
wants to merge 1 commit into from

Conversation

alalek
Copy link
Member

@alalek alalek commented May 29, 2022

successor of #21948

@asmorkalov asmorkalov requested a review from rogday May 30, 2022 15:19
Copy link
Member

@rogday rogday left a comment

Choose a reason for hiding this comment

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

Thank you!

if (!initialized.load(std::memory_order_acquire))
#else
if (!initialized)
#endif
{
sdiv_table[0] = hdiv_table180[0] = hdiv_table256[0] = 0;
Copy link
Member

Choose a reason for hiding this comment

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

I think it's a data race to write the values from different threads to one memory location, even if these values are the same. It might be better to create a struct with those tables and perform calculations in constructor. Then just create static variable of that type and c++11 will guarantee that the initialization is thread-safe.

Copy link
Member Author

Choose a reason for hiding this comment

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

replaced by #22061

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants