MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / robj_sharedptr

Class robj_sharedptr

src/server.h:239–307  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

237void decrRefCount(robj_roptr o);
238void incrRefCount(robj_roptr o);
239class robj_sharedptr
240{
241 redisObject *m_ptr;
242
243public:
244 robj_sharedptr()
245 : m_ptr(nullptr)
246 {}
247 explicit robj_sharedptr(redisObject *ptr)
248 : m_ptr(ptr)
249 {
250 if(m_ptr)
251 incrRefCount(ptr);
252 }
253 ~robj_sharedptr()
254 {
255 if (m_ptr)
256 decrRefCount(m_ptr);
257 }
258 robj_sharedptr(const robj_sharedptr& other)
259 : m_ptr(other.m_ptr)
260 {
261 if(m_ptr)
262 incrRefCount(m_ptr);
263 }
264
265 robj_sharedptr(robj_sharedptr&& other)
266 {
267 m_ptr = other.m_ptr;
268 other.m_ptr = nullptr;
269 }
270
271 robj_sharedptr &operator=(const robj_sharedptr& other)
272 {
273 robj_sharedptr tmp(other);
274 using std::swap;
275 swap(m_ptr, tmp.m_ptr);
276 return *this;
277 }
278 robj_sharedptr &operator=(redisObject *ptr)
279 {
280 robj_sharedptr tmp(ptr);
281 using std::swap;
282 swap(m_ptr, tmp.m_ptr);
283 return *this;
284 }
285
286 redisObject* operator->() const
287 {
288 return m_ptr;
289 }
290
291 bool operator!() const
292 {
293 return !m_ptr;
294 }
295
296 explicit operator bool() const{

Callers 2

addSubexpireKeyMethod · 0.85
clientArgsFunction · 0.85

Calls 1

swapFunction · 0.50

Tested by

no test coverage detected