|
Boost : |
From: Philippe A. Bouchard (philippeb_at_[hidden])
Date: 2002-09-03 12:53:58
Larry Evans wrote:
[...]
> parent. This leaves
> the non-zero rc pointers only on stack. These are then traced to find
> the live rc pointers.
> The rest are collected. Hence, the time taken would be comparable to
> that taken by
> a regular conservative GC. The only difference it the method to
> enumerate the rc pointers
> on the stack.
What about implementing some exception when get_count() == 2. Given:
bool is_on_data(void * p); // Confirm p is address on data segment
bool is_on_stack(void * p); // Confirm p is address on stack segment
bool is_on_heap(void * p); // Confirm p is address on heap segment
struct placed_ptr_header
{
int m_count;
void * m_owner; // Could point to stacked candidate for destruction
};
placed_ptr<T>::placed_ptr(...)
{
if (is_on_stack(this))
{
get_owner() = this;
}
...
}
placed_ptr<T>::~placed_ptr()
{
if (m_ptr)
{
-- get_count();
if (get_count() == 0)
{
m_ptr->~T();
free(m_ptr - ...);
}
else if (get_count() == 1 && get_owner() == this)
{
m_ptr->~T();
free(m_ptr - ...);
}
}
}
This is highly simplified and I'm not sure where this will lead to yet.
-- Philippe A. Bouchard
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk