$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Achilleas Margaritis (axilmar_at_[hidden])
Date: 2006-01-11 11:39:01
"Larry Evans" <cppljevans_at_[hidden]> wrote in message 
news:dq3b38$sme$1_at_sea.gmane.org...
> 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]
No, the new object will be placed in a thread-local-storage list by operator 
new.
Here is the sequence of operations:
1) operator new is invoked: it allocates memory for the new block and places 
the block in a thread-local-storage object list.
2) gc_ptr::CTOR is invoked: it looks at the last entry of the 
thread-local-storage object list. If not inside that block, it adds itself 
to the thread-local-storage pointer stack.
>
> _______________________________________________
> Unsubscribe & other changes: 
> http://listarchives.boost.org/mailman/listinfo.cgi/boost
>