void BlueStore::Enode::put()
{
- int final = nref.dec();
+ int final = --nref;
if (final == 0) {
dout(20) << __func__ << " removing self from set " << enode_set << dendl;
enode_set->uset.erase(*this);
#undef dout_prefix
#define dout_prefix *_dout << "bluestore.onode(" << this << ") "
-BlueStore::Onode::Onode(const ghobject_t& o, const string& k)
- : nref(0),
- oid(o),
- key(k),
- dirty(false),
- exists(true) {
-}
-
void BlueStore::Onode::flush()
{
std::unique_lock<std::mutex> l(flush_lock);
--p;
while (num > 0) {
Onode *o = &*p;
- int refs = o->nref.read();
+ int refs = o->nref.load();
if (refs > 1) {
dout(20) << __func__ << " " << o->oid << " has " << refs
<< " refs; stopping with " << num << " left to trim" << dendl;
#include <unistd.h>
+#include <atomic>
#include <mutex>
#include <condition_variable>
struct EnodeSet;
struct Enode : public boost::intrusive::unordered_set_base_hook<> {
- atomic_t nref; ///< reference count
+ std::atomic_int nref; ///< reference count
uint32_t hash;
string key; ///< key under PREFIX_OBJ where we are stored
EnodeSet *enode_set; ///< reference to the containing set
enode_set(s) {}
void get() {
- nref.inc();
+ ++nref;
}
void put();
/// an in-memory object
struct Onode {
- atomic_t nref; ///< reference count
+ std::atomic_int nref; ///< reference count
ghobject_t oid;
string key; ///< key under PREFIX_OBJ where we are stored
uint64_t tail_offset;
bufferlist tail_bl;
- Onode(const ghobject_t& o, const string& k);
+ Onode(const ghobject_t& o, const string& k)
+ : nref(0),
+ oid(o),
+ key(k),
+ dirty(false),
+ exists(true) {
+ }
void flush();
void get() {
- nref.inc();
+ ++nref;
}
void put() {
- if (nref.dec() == 0)
+ if (--nref == 0)
delete this;
}