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

Add comment about thread-safety when OPENEXR_ENABLE_THREADING is disabled #1908

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

darbyjohnston
Copy link
Contributor

This PR adds a small comment about thread-safety when the cmake option OPENEXR_ENABLE_THREADING is disabled.

This addresses the crash I found here:
#1902

Signed-off-by: Darby Johnston <[email protected]>
@@ -40,7 +40,8 @@ set(IEX_NAMESPACE "Iex" CACHE STRING "Public namespace alias for Iex")
option(OPENEXR_INSTALL_PKG_CONFIG "Install OpenEXR.pc file" ON)

# Whether to enable threading. This can be disabled, although thread pool and tasks
# are still used, just processed immediately
Copy link
Contributor

Choose a reason for hiding this comment

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

@kdt3rd, I think the existing comment although thread pool and tasks are still used is no longer true, right? Even if ENABLE_THREADING is ON, then no threadpool is created unless setGlobalThreadCount(n) is called with nonzero n, but OpenEXR will still be thread-safe. I think this what was originally wanted in #1902. ENABLE_THREADING should only be set to OFF on systems which do not support threading

Copy link
Contributor

Choose a reason for hiding this comment

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

oh, it is still true technically, in that there is a "default" thread pool that has no threads running. And the writing classes will still add tasks to that threadpool until the next significant release even when threads == 0 (where when threads == 0, the reading classes don't incur that overhead. However yes, ENABLE_THREADING should be on for 99% of use cases, especially now that pthread and such are just part of libc on most systems, and only reserved for use on systems where no threading primitives are available, or threads are guaranteed to not be employed as it makes the library non-reentrant and non-threadsafe

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.

3 participants