1 #ifndef sprockit_refcount_ptr_h 2 #define sprockit_refcount_ptr_h 7 #if SPKT_ATOMIC_REFCOUNT 8 #define ref_increment(refcount) __atomic_add_fetch(&refcount, 1, __ATOMIC_SEQ_CST) 9 #define ref_decrement_return(refcount) __atomic_add_fetch(&refcount, -1, __ATOMIC_SEQ_CST) 10 inline int fetch_and_add(
int * variable,
int value) {
11 asm volatile(
"lock; xaddl %%eax, %2;" 13 :
"a" (value),
"m" (*variable)
18 #define ref_increment(refcount) ++refcount 19 #define ref_decrement_return(refcount) --refcount 94 operator bool()
const {
111 #if __cplusplus > 199711L 114 template <
class T>
struct hash<sprockit::
refcount_ptr<T> > {
117 return hash<void*>()(ptr.
get());
#define ref_decrement_return(refcount)
refcount_ptr< T > & operator=(const refcount_ptr< U > &rhs)
refcount_ptr< T > & operator=(T *rhs)
refcount_ptr(const refcount_ptr< U > &rhs)
refcount_ptr(const refcount_ptr &rhs)
refcount_ptr< T > & operator=(const refcount_ptr &rhs)
#define ref_increment(refcount)