Skip to content

Commit

Permalink
Try atomic
Browse files Browse the repository at this point in the history
Signed-off-by: Larry Gritz <[email protected]>
  • Loading branch information
lgritz committed Apr 16, 2024
1 parent 0339ac1 commit c194112
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/libOpenImageIO/imageinput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,18 @@ static thread_local tsl::robin_map<const ImageInput*, std::string>
// destroyed.
class LiveStaticSentry {
public:
LiveStaticSentry()
: m_alive(1)
{
}
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; }
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:
int m_alive = 0;
atomic_int m_alive { 0 };
};

static LiveStaticSentry statics_alive;
Expand Down

0 comments on commit c194112

Please sign in to comment.