Boost logo

Boost :

From: Greg Colvin (Gregory.Colvin_at_[hidden])
Date: 2002-08-11 21:44:47

At 02:14 PM 08/11/2002, Philippe A. Bouchard wrote:
>> As for the implementation, I think there are better approaches that
>> would cause no penalty for get(). The usual trick is to use size-
>> segregated storage pools set up so that one can get from an interior
>> pointer to an object header very quickly.
>Yeah... interesting... but the copy contructor will have to go thru the
>lookup table instead?

Why? To increment the count?

>How much required time in your opinion?

Depends on the implementation and the hardware. Let's assume that
the hardware lets us twiddle the bits of a pointer as if it was an
unsigned int, and that at the beginning of the page we store the
mask for getting to an object header, then referencing the counter
would be two masks and two memory accesses:

   inline unsigned get_page_mask(void* object) {
      return *(unsigned*)(unsigned(object)&PAGE_MASK);
   inline unsigned& get_count_ref(void* object) {
      return *(unsigned*)(unsigned(object)&get_page_mask(object));

Boost list run by bdawes at, gregod at, cpdaniel at, john at