Another try at fixing our 'spinlock_t' compatibility
This commit is contained in:
parent
82bdb48dab
commit
bf5da033dc
@ -20,6 +20,8 @@
|
|||||||
#define _pbd_spinlock_h_
|
#define _pbd_spinlock_h_
|
||||||
|
|
||||||
#include <boost/smart_ptr/detail/spinlock.hpp>
|
#include <boost/smart_ptr/detail/spinlock.hpp>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
#include "pbd/libpbd_visibility.h"
|
#include "pbd/libpbd_visibility.h"
|
||||||
|
|
||||||
namespace PBD {
|
namespace PBD {
|
||||||
@ -35,10 +37,23 @@ namespace PBD {
|
|||||||
|
|
||||||
struct spinlock_t {
|
struct spinlock_t {
|
||||||
public:
|
public:
|
||||||
spinlock_t ();
|
#ifdef BOOST_SMART_PTR_DETAIL_SPINLOCK_STD_ATOMIC_HPP_INCLUDED
|
||||||
|
/* C++11 non-static data member initialization,
|
||||||
|
* with non-copyable std::atomic ATOMIC_FLAG_INIT
|
||||||
|
*/
|
||||||
|
spinlock_t () : l (BOOST_DETAIL_SPINLOCK_INIT) {};
|
||||||
|
#else
|
||||||
|
/* default C++ assign struct's first member */
|
||||||
|
spinlock_t ()
|
||||||
|
{
|
||||||
|
boost::detail::spinlock init = BOOST_DETAIL_SPINLOCK_INIT;
|
||||||
|
std::memcpy (&l, &init, sizeof (init));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
void lock () { l.lock (); }
|
void lock () { l.lock (); }
|
||||||
void unlock () { l.unlock (); }
|
void unlock () { l.unlock (); }
|
||||||
bool try_lock () { return l.try_lock (); }
|
bool try_lock () { return l.try_lock (); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
boost::detail::spinlock l;
|
boost::detail::spinlock l;
|
||||||
|
|
||||||
|
@ -16,31 +16,10 @@
|
|||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef PLATFORM_WINDOWS
|
|
||||||
#include <windows.h>
|
|
||||||
#include <malloc.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
#include "pbd/spinlock.h"
|
#include "pbd/spinlock.h"
|
||||||
|
|
||||||
using namespace PBD;
|
using namespace PBD;
|
||||||
|
|
||||||
spinlock_t::spinlock_t ()
|
|
||||||
#ifdef BOOST_SMART_PTR_DETAIL_SPINLOCK_STD_ATOMIC_HPP_INCLUDED
|
|
||||||
/* C++11 non-static data member initialization,
|
|
||||||
* with non-copyable std::atomic ATOMIC_FLAG_INIT
|
|
||||||
*/
|
|
||||||
: l {BOOST_DETAIL_SPINLOCK_INIT} {}
|
|
||||||
#else
|
|
||||||
/* default C++ assign struct's first member */
|
|
||||||
{
|
|
||||||
boost::detail::spinlock init = BOOST_DETAIL_SPINLOCK_INIT;
|
|
||||||
std::memcpy (&l, &init, sizeof (init));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
SpinLock::SpinLock (spinlock_t& lock)
|
SpinLock::SpinLock (spinlock_t& lock)
|
||||||
: _lock (lock)
|
: _lock (lock)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user