Boost logo

Boost :

From: Larry Evans (cppljevans_at_[hidden])
Date: 2006-01-11 11:16:39


On 01/11/2006 09:56 AM, Achilleas Margaritis wrote:
> "Larry Evans" <cppljevans_at_[hidden]> wrote in message
[snip]
>>> gc_ptr() {
>>> if this not within last created object then {
>>
>>This test, IIUC, requires access to a global object
>>(pointer to last created object or something similar).
>>Wouldn't this then require synchronization between
>>threads; hence, cause a big slowdown for each gc_ptr
>>creation?
>
>
> If the pointer stack is thread-specific storage, then synchronization is not
> be needed.
>
Ah, yes. I failed to remember you first post mentioned:

> a) each garbage-collected thread shall have its own pointer stack allocated
> as thread-local-storage. The size of the pointer stack shall be analogous to
> the size of the hardware stack for the size of pointer of the machine.

Now, wouldn't this require the gc_ptr::CTOR to *never* take a raw
pointer? This is because to test:

    this not within last created object

within gc_ptr::CTOR, the pointee to the last created object
would have to be stored in some thread-local-storage by another gc_ptr,
and the only way this could happen is if the first gc_ptr first:

    1) allocated the storage for the pointee
    2) stored the last-created-pointer in some thread-local-storage
    3) created the pointee with placement new (this requiring
       knowlege about the pointee's CTOR)
    4) then zeroed the last-created-pointer

Does this make sense?
[snip]


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk