52 #ifndef __PCL_Atomic_h
53 #define __PCL_Atomic_h
61 # pragma intrinsic (_InterlockedIncrement)
62 # pragma intrinsic (_InterlockedDecrement)
63 # pragma intrinsic (_InterlockedCompareExchange)
64 # pragma intrinsic (_InterlockedExchange)
65 # pragma intrinsic (_InterlockedExchangeAdd)
134 bool operator !()
const
183 return FetchAndAdd( 0 );
196 (void)FetchAndStore( newValue );
210 (void)_InterlockedIncrement( &m_value );
212 asm volatile(
"lock\n\t"
231 (void)_InterlockedDecrement( &m_value );
233 asm volatile(
"lock\n\t"
253 return _InterlockedIncrement( &m_value ) != 0;
256 asm volatile(
"lock\n\t"
259 :
"=m" (m_value),
"=qm" (result)
278 return _InterlockedDecrement( &m_value ) != 0;
281 asm volatile(
"lock\n\t"
284 :
"=m" (m_value),
"=qm" (result)
305 return _InterlockedCompareExchange( &m_value, newValue, expectedValue ) == expectedValue;
308 asm volatile(
"lock\n\t"
311 :
"=a" (newValue),
"=qm" (result),
"+m" (m_value)
312 :
"r" (newValue),
"0" (expectedValue)
330 return _InterlockedExchange( &m_value, newValue );
332 asm volatile(
"xchgl %0,%1\n"
333 :
"=r" (newValue),
"+m" (m_value)
350 return _InterlockedExchangeAdd( &m_value, valueToAdd );
352 asm volatile(
"lock\n\t"
354 :
"=r" (valueToAdd),
"+m" (m_value)
364 __declspec(align(4)) volatile
long m_value;
366 volatile int m_value __attribute__ ((aligned (4)));
486 operator bool()
const volatile
494 bool m_guarded =
false;
506 #define PCL_REENTRANCY_GUARDED_BEGIN \
508 static pcl::AtomicInt __r_g__( 0 ); \
509 volatile pcl::AutoReentrancyGuard __a_r_g__( __r_g__ ); \
522 #define PCL_REENTRANCY_GUARDED_END \
570 #define PCL_CLASS_REENTRANCY_GUARD \
571 mutable pcl::AtomicInt __pcl_guard__;
586 #define PCL_CLASS_REENTRANCY_GUARDED_BEGIN \
588 volatile pcl::AutoReentrancyGuard __a_r_g__( __pcl_guard__ ); \
637 #define PCL_MEMBER_REENTRANCY_GUARD( member ) \
638 mutable pcl::AtomicInt __pcl_guard_##member##__;
653 #define PCL_MEMBER_REENTRANCY_GUARDED_BEGIN( member ) \
655 volatile pcl::AutoReentrancyGuard __a_r_g__( __pcl_guard_##member##__ );\
Atomic operations on integers.
AtomicInt(const AtomicInt &)=default
int FetchAndAdd(int valueToAdd)
int FetchAndStore(int newValue)
bool TestAndSet(int expectedValue, int newValue)
Automatic reentrancy guard sentinel.
AutoReentrancyGuard(AtomicInt &guard)
bool operator==(const Array< T, A > &x1, const Array< T, A > &x2) noexcept
bool operator!=(const T1 &a, const T2 &b)