mirror of
https://github.com/Xahau/xahaud.git
synced 2025-11-30 23:45:48 +00:00
Fix SharedSingleton to use memoryBarrier
This commit is contained in:
@@ -92,6 +92,7 @@ public:
|
||||
bassert (lifetime == SingletonLifetime::createOnDemand || ! staticData.destructorCalled);
|
||||
staticData.instance = &staticData.object;
|
||||
new (staticData.instance) SharedSingleton (lifetime);
|
||||
memoryBarrier();
|
||||
instance = staticData.instance;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,9 +131,6 @@ public:
|
||||
*/
|
||||
Type compareAndSetValue (Type newValue, Type valueToCompare) noexcept;
|
||||
|
||||
/** Implements a memory read/write barrier. */
|
||||
static void memoryBarrier() noexcept;
|
||||
|
||||
//==============================================================================
|
||||
#if BEAST_64BIT
|
||||
BEAST_ALIGN (8)
|
||||
@@ -373,8 +370,7 @@ inline Type Atomic<Type>::compareAndSetValue (const Type newValue, const Type va
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename Type>
|
||||
inline void Atomic<Type>::memoryBarrier() noexcept
|
||||
inline void memoryBarrier() noexcept
|
||||
{
|
||||
#if BEAST_ATOMICS_MAC
|
||||
OSMemoryBarrier();
|
||||
@@ -389,4 +385,5 @@ inline void Atomic<Type>::memoryBarrier() noexcept
|
||||
#pragma warning (pop)
|
||||
#endif
|
||||
|
||||
#endif // BEAST_ATOMIC_H_INCLUDED
|
||||
#endif
|
||||
|
||||
|
||||
@@ -322,14 +322,14 @@ public:
|
||||
test.expect (a.get() == (Type) 10);
|
||||
a += (Type) 15;
|
||||
test.expect (a.get() == (Type) 25);
|
||||
a.memoryBarrier();
|
||||
memoryBarrier();
|
||||
a -= (Type) 5;
|
||||
test.expect (a.get() == (Type) 20);
|
||||
test.expect (++a == (Type) 21);
|
||||
++a;
|
||||
test.expect (--a == (Type) 21);
|
||||
test.expect (a.get() == (Type) 21);
|
||||
a.memoryBarrier();
|
||||
memoryBarrier();
|
||||
|
||||
testFloat (test);
|
||||
}
|
||||
@@ -338,7 +338,7 @@ public:
|
||||
{
|
||||
Atomic<Type> a, b;
|
||||
a = (Type) 21;
|
||||
a.memoryBarrier();
|
||||
memoryBarrier();
|
||||
|
||||
/* These are some simple test cases to check the atomics - let me know
|
||||
if any of these assertions fail on your system!
|
||||
|
||||
@@ -21,7 +21,7 @@ int UptimeTimer::getElapsedSeconds () const
|
||||
|
||||
if (m_isUpdatingManually)
|
||||
{
|
||||
// memoryBarrier();
|
||||
memoryBarrier();
|
||||
result = m_elapsedTime;
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user