From 8a8468c5f15549469b79680be3b8a99478f4bab5 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 26 Jul 2019 21:40:39 +0200 Subject: [PATCH] Correctly initialize spintlock_t Depending on underlying implementation, boost::detail::spinlock needs to be explicitly initialized --- libs/pbd/pbd/playback_buffer.h | 1 - libs/pbd/pbd/spinlock.h | 12 +++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/libs/pbd/pbd/playback_buffer.h b/libs/pbd/pbd/playback_buffer.h index d41adea2e2..53c9531d39 100644 --- a/libs/pbd/pbd/playback_buffer.h +++ b/libs/pbd/pbd/playback_buffer.h @@ -41,7 +41,6 @@ public: PlaybackBuffer (guint sz, guint res = 8191) : reservation (res) - , _reservation_lock () { sz += reservation; size = power_of_two_size (sz); diff --git a/libs/pbd/pbd/spinlock.h b/libs/pbd/pbd/spinlock.h index eb784ac6ce..41c40543f0 100644 --- a/libs/pbd/pbd/spinlock.h +++ b/libs/pbd/pbd/spinlock.h @@ -29,8 +29,18 @@ namespace PBD { * bool try_lock(); * void unlock(); * }; + * + * initialize with BOOST_DETAIL_SPINLOCK_INIT */ -typedef boost::detail::spinlock spinlock_t; +struct spinlock_t { +public: + spinlock_t () : l (BOOST_DETAIL_SPINLOCK_INIT) {}; + void lock () { l.lock (); } + void unlock () { l.unlock (); } + bool try_lock () { return l.try_lock (); } +private: + boost::detail::spinlock l; +}; /* RAII wrapper */ class LIBPBD_API SpinLock { -- 2.30.2