|
Boost : |
From: Achilleas Margaritis (axilmar_at_[hidden])
Date: 2006-01-11 10:56:39
"Larry Evans" <cppljevans_at_[hidden]> wrote in message
news:dq36jf$7c0$1_at_sea.gmane.org...
> On 01/11/2006 08:27 AM, Achilleas Margaritis wrote:
> [snip]
>> -------------------------------------------------------
>> Alternative 1 - using gc_ptr<T> for global, stack and member pointers.
>>
>> It is possible to use the gc_ptr class for global, stack and member
>> pointers. The class would have to check if it belongs in the last-known
>> created object by checking its address against the address of the last
>> created object. If the pointer falls within the memory area of the last
>> created object, then it is a member pointer, otherwise it is a
>> global/stack
>> pointer. Example code:
>>
>> template < class T > class gc_ptr {
>> public:
>> 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.
>
>> pointer stack->push(this);
>> }
>> }
>> };
>>
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk