13
0

Correctly initialize spintlock_t

Depending on underlying implementation, boost::detail::spinlock
needs to be explicitly initialized
This commit is contained in:
Robin Gareus 2019-07-26 21:40:39 +02:00
parent 8a969b56c9
commit 8a8468c5f1
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
2 changed files with 11 additions and 2 deletions

View File

@ -41,7 +41,6 @@ public:
PlaybackBuffer (guint sz, guint res = 8191)
: reservation (res)
, _reservation_lock ()
{
sz += reservation;
size = power_of_two_size (sz);

View File

@ -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 {