13
0

Another try at C++11/boost spinlock initialization

This commit is contained in:
Robin Gareus 2019-09-26 02:47:16 +02:00
parent 8ab5db0d67
commit 5395a557d2
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04

View File

@ -41,7 +41,7 @@ public:
/* C++11 non-static data member initialization, /* C++11 non-static data member initialization,
* with non-copyable std::atomic ATOMIC_FLAG_INIT * with non-copyable std::atomic ATOMIC_FLAG_INIT
*/ */
spinlock_t () : l {BOOST_DETAIL_SPINLOCK_INIT} {}; spinlock_t () {}
#else #else
/* default C++ assign struct's first member */ /* default C++ assign struct's first member */
spinlock_t () spinlock_t ()
@ -55,7 +55,11 @@ public:
bool try_lock () { return l.try_lock (); } bool try_lock () { return l.try_lock (); }
private: private:
#ifdef BOOST_SMART_PTR_DETAIL_SPINLOCK_STD_ATOMIC_HPP_INCLUDED
boost::detail::spinlock l = BOOST_DETAIL_SPINLOCK_INIT;
#else
boost::detail::spinlock l; boost::detail::spinlock l;
#endif
/* prevent copy construction */ /* prevent copy construction */
spinlock_t (const spinlock_t&); spinlock_t (const spinlock_t&);