diff --git a/src/libOpenImageIO/imageinput.cpp b/src/libOpenImageIO/imageinput.cpp index 13e193eae0..67d69df819 100644 --- a/src/libOpenImageIO/imageinput.cpp +++ b/src/libOpenImageIO/imageinput.cpp @@ -30,27 +30,6 @@ using namespace pvt; // store an error message per thread, for a specific ImageInput static thread_local tsl::robin_map input_error_messages; - -// Helper class that, for any instance thereof, reveals whether any statics in -// the same compilation unit have been initialized or destroyed. If the -// statics are still alive, it looks like true, but it will look like false if -// evaluated before file-scope statics are initialized or after they are -// destroyed. -class LiveStaticSentry { -public: - LiveStaticSentry() - : m_alive(1) - { - } - ~LiveStaticSentry() { m_alive = 0; } - // int operator()() const { return m_alive; } - operator bool() const { return m_alive; } - bool alive() const { return m_alive; } - -private: - int m_alive = 0; -}; - static LiveStaticSentry statics_alive; diff --git a/src/libOpenImageIO/imageio_pvt.h.in b/src/libOpenImageIO/imageio_pvt.h.in index 1f6d061018..15dc1609f5 100644 --- a/src/libOpenImageIO/imageio_pvt.h.in +++ b/src/libOpenImageIO/imageio_pvt.h.in @@ -193,6 +193,30 @@ bluenoise_4chan_ptr(int x, int y, int z, int ch = 0, int seed = 0) +// Helper class that, for any instance thereof, reveals whether any statics in +// the same compilation unit have been initialized or destroyed. If the +// statics are still alive, it looks like true, but it will look like false if +// evaluated before file-scope statics are initialized or after they are +// destroyed. +class LiveStaticSentry { +public: + LiveStaticSentry() { m_alive = 1; } + ~LiveStaticSentry() { m_alive = 0; } + operator bool() const { return alive(); } + bool alive() const + { + int a = m_alive; + // if (!a) + // print("LiveStaticSentry::alive() called after static destruction\n"); + return a; + } + +private: + atomic_int m_alive { 0 }; +}; + + + struct print_info_options { bool verbose = false; bool filenameprefix = false;