SHOGUN
v3.2.0
|
00001 #ifdef HAVE_CXX11_ATOMIC 00002 #include <atomic> 00003 #endif 00004 00005 #include <shogun/lib/common.h> 00006 #include <shogun/lib/Lock.h> 00007 00008 #ifndef _REFCOUNT__H__ 00009 #define _REFCOUNT__H__ 00010 00011 namespace shogun 00012 { 00016 class RefCount 00017 { 00018 public: 00023 RefCount(int32_t ref_start=0) : rc(ref_start) {} 00024 00029 int32_t ref(); 00030 00035 int32_t unref(); 00036 00041 int32_t ref_count(); 00042 00044 #ifdef HAVE_CXX11_ATOMIC 00045 volatile std::atomic<int> rc; 00046 #else 00047 int32_t rc; 00048 00050 CLock lock; 00051 #endif 00052 }; 00053 } 00054 00055 #endif //_REFCOUNT__H__