diff options
author | Robin Gareus <robin@gareus.org> | 2019-07-28 14:57:51 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2019-07-28 14:57:51 +0200 |
commit | d382b756c2e832bbb8a5778d704c8310ad19ad57 (patch) | |
tree | 98862e014108072b42e33282ddd9b8d6221c1f5f /libs | |
parent | d8ae3fd3a6a4c15b1bb650c9bc9e6b5369c30912 (diff) |
Follow up d8ae3fd
Depending on implementation, d8ae3fd may only construct the spinlock
once to `sl_init`. Later it is only copy-constructed and that leads to
compile and/or runtmime errors.
e.g. gcc-8.3 fails to compile
error: use of deleted function ‘boost::detail::spinlock::spinlock(const boost::detail::spinlock&)’
Diffstat (limited to 'libs')
-rw-r--r-- | libs/pbd/pbd/spinlock.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/libs/pbd/pbd/spinlock.h b/libs/pbd/pbd/spinlock.h index 7173fde594..69b76ce820 100644 --- a/libs/pbd/pbd/spinlock.h +++ b/libs/pbd/pbd/spinlock.h @@ -32,11 +32,17 @@ namespace PBD { * * initialize with BOOST_DETAIL_SPINLOCK_INIT */ -static boost::detail::spinlock sl_init = BOOST_DETAIL_SPINLOCK_INIT; +#ifdef COMPILER_MSVC +private: + static boost::detail::spinlock sl_init = BOOST_DETAIL_SPINLOCK_INIT; +# define SPINLOCK_INIT sl_init +#else +# define SPINLOCK_INIT BOOST_DETAIL_SPINLOCK_INIT +#endif struct spinlock_t { public: - spinlock_t () : l (sl_init) {}; + spinlock_t () : l (SPINLOCK_INIT) {}; void lock () { l.lock (); } void unlock () { l.unlock (); } bool try_lock () { return l.try_lock (); } @@ -44,6 +50,8 @@ private: boost::detail::spinlock l; }; +#undef SPINLOCK_INIT + /* RAII wrapper */ class LIBPBD_API SpinLock { |