提交 fc190687 创建 作者: Nickolai Zeldovich's avatar Nickolai Zeldovich

rcu_freed base class. need to convert all RCU users to new interface

before we can use it, which also requires convering all namespace users to templatized namespace..
上级 c84b6d9c
...@@ -26,7 +26,7 @@ COMFLAGS := -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall \ ...@@ -26,7 +26,7 @@ COMFLAGS := -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall \
-DHW_$(HW) -include param.h -include compiler.h -DHW_$(HW) -include param.h -include compiler.h
COMFLAGS += $(shell $(CC) -fno-stack-protector -E -x c /dev/null >/dev/null 2>&1 && echo -fno-stack-protector) COMFLAGS += $(shell $(CC) -fno-stack-protector -E -x c /dev/null >/dev/null 2>&1 && echo -fno-stack-protector)
CFLAGS := $(COMFLAGS) -std=c99 CFLAGS := $(COMFLAGS) -std=c99
CXXFLAGS := $(COMFLAGS) -std=c++0x -Wno-sign-compare -fno-exceptions CXXFLAGS := $(COMFLAGS) -std=c++0x -Wno-sign-compare -fno-exceptions -fno-rtti
ASFLAGS = -m64 -gdwarf-2 -MD ASFLAGS = -m64 -gdwarf-2 -MD
LDFLAGS += -m elf_x86_64 LDFLAGS += -m elf_x86_64
......
...@@ -336,3 +336,10 @@ initgc(void) ...@@ -336,3 +336,10 @@ initgc(void)
release(&gcp->lock); release(&gcp->lock);
} }
} }
void
del_rcu_freed(void *arg)
{
rcu_freed *rf = (rcu_freed*) arg;
delete rf;
}
#pragma once
class rcu_freed {
private:
u64 _rcu_epoch;
rcu_freed *_rcu_next;
public:
virtual ~rcu_freed() {}
};
void del_rcu_freed(void*);
#pragma once #pragma once
#include "gc.hh"
// name spaces // name spaces
// XXX maybe use open hash table, no chain, better cache locality // XXX maybe use open hash table, no chain, better cache locality
...@@ -16,7 +18,7 @@ class scoped_gc_epoch { ...@@ -16,7 +18,7 @@ class scoped_gc_epoch {
}; };
template<class K, class V> template<class K, class V>
class xelem { class xelem : public rcu_freed {
public: public:
V val; V val;
int next_lock; int next_lock;
...@@ -24,6 +26,7 @@ class xelem { ...@@ -24,6 +26,7 @@ class xelem {
K key; K key;
xelem(const K &k, const V &v) : val(v), next_lock(0), next(0), key(k) {} xelem(const K &k, const V &v) : val(v), next_lock(0), next(0), key(k) {}
virtual ~xelem() {}
}; };
template<class K, class V> template<class K, class V>
...@@ -73,7 +76,7 @@ class xns { ...@@ -73,7 +76,7 @@ class xns {
if (!allowdup) { if (!allowdup) {
for (auto x = root; x; x = x->next) { for (auto x = root; x; x = x->next) {
if (x->key == key) { if (x->key == key) {
// XXX delete e; gc_delayed(e, del_rcu_freed);
return -1; return -1;
} }
} }
...@@ -128,7 +131,7 @@ class xns { ...@@ -128,7 +131,7 @@ class xns {
} }
*pelock = 0; *pelock = 0;
// XXX delete e; gc_delayed(e, del_rcu_freed);
return true; return true;
} }
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论