Remove root_rcp

This commit is contained in:
Josh Holtrop 2026-02-23 22:29:03 -05:00
parent 3fdb7c9bc6
commit a70a0218dc

View File

@ -33,16 +33,17 @@ class rcp
private:
T * ptr = nullptr;
void init_ptr(T * p)
{
ptr = p;
}
friend T;
public:
rcp() = default;
rcp(T * p) : ptr(p)
{
if (p)
{
p->rcp_inc();
}
}
rcp(const rcp & other) : ptr(other.ptr)
{
if (ptr)
@ -101,13 +102,6 @@ private:
mutable std::atomic<int> ref_count{0};
protected:
mutable rcp<root> root_rcp;
root()
{
root_rcp.init_ptr(this);
}
virtual ~root() = default;
public:
@ -120,7 +114,6 @@ public:
{
if (ref_count.fetch_sub(1, std::memory_order_acq_rel) == 1)
{
root_rcp.init_ptr(nullptr);
delete this;
}
}
@ -129,7 +122,7 @@ public:
#define rcp_managed(classname) \
rcp<classname> get_rcp() \
{ \
return rcp<classname>(root_rcp); \
return rcp<classname>(this); \
} \
template <typename... Args> \
static rcp<classname> create(Args&&... args) \