Skip to content

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

Closed
alalek wants to merge 1 commit intoopencv:3.4from
alalek:imgproc_color_hsv_use_std_atomic
Closed

imgproc: use C++11 std::atomic in color_hsv.simd.hpp#22050
alalek wants to merge 1 commit intoopencv:3.4from
alalek:imgproc_color_hsv_use_std_atomic

Conversation

@alalek
Copy link
Copy Markdown
Member

@alalek alalek commented May 29, 2022

successor of #21948

@asmorkalov asmorkalov requested a review from rogday May 30, 2022 15:19
Copy link
Copy Markdown
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)
#endif
{
sdiv_table[0] = hdiv_table180[0] = hdiv_table256[0] = 0;
Copy link
Copy Markdown
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
Copy Markdown
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants