Another attempt at improving spinlock init
This commit is contained in:
parent
d382b756c2
commit
d00650c2fd
|
@ -32,17 +32,10 @@ namespace PBD {
|
|||
*
|
||||
* initialize with 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 (SPINLOCK_INIT) {};
|
||||
spinlock_t ();
|
||||
void lock () { l.lock (); }
|
||||
void unlock () { l.unlock (); }
|
||||
bool try_lock () { return l.try_lock (); }
|
||||
|
@ -50,8 +43,6 @@ private:
|
|||
boost::detail::spinlock l;
|
||||
};
|
||||
|
||||
#undef SPINLOCK_INIT
|
||||
|
||||
/* RAII wrapper */
|
||||
class LIBPBD_API SpinLock {
|
||||
|
||||
|
|
|
@ -25,6 +25,11 @@
|
|||
|
||||
using namespace PBD;
|
||||
|
||||
spinlock_t::spinlock_t ()
|
||||
{
|
||||
l = BOOST_DETAIL_SPINLOCK_INIT;
|
||||
}
|
||||
|
||||
SpinLock::SpinLock (spinlock_t& lock)
|
||||
: _lock (lock)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user