Skip to content

Commit

Permalink
Fix data race for type ID generation
Browse files Browse the repository at this point in the history
  • Loading branch information
audaki committed Oct 16, 2017
1 parent f9860c4 commit cd84fdf
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions include/anax/detail/ClassTypeId.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#define ANAX_DETAIL_CLASSTYPEID_HPP

#include <cstddef>
#include <atomic>

namespace anax
{
Expand All @@ -48,11 +49,11 @@ namespace anax

private:

static TypeId m_nextTypeId;
static std::atomic<TypeId> m_nextTypeId;
};

template <typename TBase>
TypeId ClassTypeId<TBase>::m_nextTypeId = 0;
std::atomic<TypeId> ClassTypeId<TBase>::m_nextTypeId{0};
}
}

Expand Down

0 comments on commit cd84fdf

Please sign in to comment.