diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2017-11-06 13:44:46 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2017-11-06 13:44:46 +0200 |
commit | 702c5756d5a2050327603cb9e507c839f928a7a3 (patch) | |
tree | 2886b831eba8de926d42882fad8d043a2400ad4a /odb/details/shared-ptr/base.hxx | |
parent | e3fe7cd2d1bc82a60445412986ea31d30e494a3d (diff) |
Make shared_base counter atomic in C++11 and up
Diffstat (limited to 'odb/details/shared-ptr/base.hxx')
-rw-r--r-- | odb/details/shared-ptr/base.hxx | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/odb/details/shared-ptr/base.hxx b/odb/details/shared-ptr/base.hxx index c042fa6..5153aba 100644 --- a/odb/details/shared-ptr/base.hxx +++ b/odb/details/shared-ptr/base.hxx @@ -7,10 +7,15 @@ #include <odb/pre.hxx> +#include <odb/details/config.hxx> // ODB_CXX11, ODB_NOTHROW_NOEXCEPT + #include <new> #include <cstddef> // std::size_t -#include <odb/details/config.hxx> // ODB_CXX11, ODB_NOTHROW_NOEXCEPT +#ifdef ODB_CXX11 +#include <atomic> +#endif + #include <odb/details/export.hxx> #include <odb/details/shared-ptr/counter-type.hxx> @@ -96,12 +101,12 @@ namespace odb bool (*zero_counter) (void*); }; - private: - bool - _dec_ref_callback (); - protected: +#ifdef ODB_CXX11 + std::atomic<std::size_t> counter_; +#else std::size_t counter_; +#endif refcount_callback* callback_; }; |