|
Boost Users : |
From: Alexander Gutenev (gutenev_at_[hidden])
Date: 2008-07-30 18:02:58
Updated, after looking into other's implementation:
template<class Derived>
class intrusive_pointee_base
{
private:
typedef intrusive_pointee_base self;
protected:
intrusive_pointee_base(void) : reference_counter_(0) {}
intrusive_pointee_base(self const&) : reference_counter_(0) {}
intrusive_pointee_base operator=(self const&) { return *this }
~intrusive_pointee_base(void) {}
private:
friend void intrusive_ptr_add_ref(const Derived * p)
{
::InterlockedIncrement(&static_cast<self const
*>(p)->reference_counter_);
}
friend void intrusive_ptr_release(const Derived * p)
{
if (!::InterlockedDecrement(&static_cast<self const
*>(p)->reference_counter_))
delete p;
}
mutable volatile long reference_counter_;
};
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net