Just added it in this commit.  Please let me know if anything looks
wrong.  it seems to work in at least one test case.

http://opensg.vrsource.org/trac/changeset/1818

-Allen

On Thu, Mar 12, 2009 at 8:00 PM, Dirk Reiners <[email protected]> wrote:
>
>        Hi Allen,
>
> Allen Bierbaum wrote:
>> On Thu, Mar 12, 2009 at 3:55 PM, Dirk Reiners <[email protected]> wrote:
>>> Allen Bierbaum wrote:
>>>> How do you keep a weak pointer across threads? Is there an MTWeakPtr
>>>> or equivalent (haven't seen it so far).
>>> Hasn't come up yet as a need.
>>
>> The place I need it is for a global geometry factory.
>>
>> I have a system that basically looks something like this:
>>
>> class Factory:
>>    std:map<style, OSG::ChunkMaterialXXX> style cache;
>>
>>    OSG::NodeMTRecPtr  buildGeomNode(myGeom* geom, Style style);
>>
>> I want to cache the style materials across multiple built geometries.
>> But once the last geometry using that cached style is removed, I don't
>> want to hold onto the material any more.  Until this morning I didn't
>> think I would be able to do this, but now I think I could do it with
>> an MTWeakPtr.  (I need MT because this can be called from multiple
>> threads)
>
> Makes sense. Would also be a nice application of it.
>
>>> Should be pretty easy to do though, just add a
>>>
>>>
>>> struct MTWeakRefCountPolicy : public WeakRefCountPolicy
>>> {
>>>     template <class T>
>>>     static T *validate   (T *pObject)
>>>     {
>>>         return convertToCurrentAspect(pObject);
>>>     }
>>>
>>>     template <class T>
>>>     static T &dereference(T *pObject)
>>>     {
>>>         return *(validate(pObject));
>>>     }
>>> };
>>>
>>> and use it. Or am I too optimistic here?
>>
>> So, where exactly would I add this in the OpenSG code?  Also, where
>> should I put the ptr type aliases?
>
> In Source/Base/FieldContainer/Base/OSGRefCountPolicies.h
>
> Aliases probably in the catch-all macros OSG_GEN_INTERNALPTR and
> OSG_GEN_CONTAINERPTR in Source/Base/Base/OSGContainerForwards.h.
>
> Let us know if it works...
>
>        Dirk
>
> ------------------------------------------------------------------------------
> Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
> powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
> easily build your RIAs with Flex Builder, the Eclipse(TM)based development
> software that enables intelligent coding and step-through debugging.
> Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
> _______________________________________________
> Opensg-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/opensg-users
>

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to