common: add RefCountedObj.cc with intrusive_ptr hooks

Signed-off-by: Samuel Just <sam.just@inktank.com>
This commit is contained in:
Samuel Just 2012-10-02 13:33:11 -07:00
parent c4981b8128
commit d12911252b
5 changed files with 28 additions and 14 deletions

View File

@ -1211,6 +1211,7 @@ libcommon_files = \
msg/Accepter.cc \
msg/DispatchQueue.cc \
msg/Message.cc \
common/RefCountedObj.cc \
msg/Messenger.cc \
msg/Pipe.cc \
msg/SimpleMessenger.cc \

View File

@ -0,0 +1,23 @@
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#include "common/RefCountedObj.h"
void intrusive_ptr_add_ref(RefCountedObject *p) {
p->get();
}
void intrusive_ptr_release(RefCountedObject *p) {
p->put();
}

View File

@ -15,6 +15,8 @@
#ifndef CEPH_REFCOUNTEDOBJ_H
#define CEPH_REFCOUNTEDOBJ_H
#include "common/Mutex.h"
#include "common/Cond.h"
#include "include/atomic.h"
@ -116,5 +118,7 @@ struct RefCountedWaitObject {
}
};
void intrusive_ptr_add_ref(RefCountedObject *p);
void intrusive_ptr_release(RefCountedObject *p);
#endif

View File

@ -152,16 +152,6 @@ using namespace std;
#define dout_subsys ceph_subsys_ms
void intrusive_ptr_add_ref(Message *p)
{
p->get();
}
void intrusive_ptr_release(Message *p)
{
p->put();
}
void Message::encode(uint64_t features, bool datacrc)
{
// encode and copy out of *m

View File

@ -480,8 +480,4 @@ inline ostream& operator<<(ostream& out, Message& m) {
extern void encode_message(Message *m, uint64_t features, bufferlist& bl);
extern Message *decode_message(CephContext *cct, bufferlist::iterator& bl);
void intrusive_ptr_add_ref(Message *p);
void intrusive_ptr_release(Message *p);
#endif