Hi Mathias, I'm just beginning the review of your submission, not far in yet but have a question/query. Looking at src/osg/Referenced.cpp I see that it contains two sets of changes - the atomic reference count changes that are to be expected, and then changes to the observer management which looks to be a knock on change required because the Mutex _refMutex disappears along with the introduction of the atomic ref counts.
My inclination would be to separate these two sets of changes, for instance leave _refMutex in place and leave the old observer code in place, then do a second submission that removes the observer code's dependence on _refMutex. The observer code itself that you have introduced does leave me a bit perplexed on a first read through, I presume the complexity is down to the attempt at avoiding the _refMutex, but suspect that as such one could still introduced potential threading problems over initialization of the observer set structure. It might be that your code is safe, but it's complex enough that I can't say this right away. Perhaps a static ref mutex might be sufficient for this particular support. Thoughts? Robert. On Mon, Jun 2, 2008 at 1:28 PM, Mathias Fröhlich <[EMAIL PROTECTED]> wrote: > > Hi Robert, > > I have implemented threadsafe reference counting using atomic operations if > available for the target platform. > > There is a configure check which searches for different implementations and > selects one that is available. > > Based on that configure check, a file include/OpenThreads/Config is created > that stores that configuration decision. > > There are two new classes in OpenThreads that serve as an abstraction for the > atomic operations. If no atomic value implementation is available at the > target platform the class falls back to using mutexes. So this class is > thread safe in any case. > > Referenced is modified to use that atomic operations for reference counting > and creation of the a mutex locked observer set pointer iff there is an > implementation for the atomic data type *without* mutex available. If we have > atomic operations with a mutex, the old strategy is used. > > In effect I get a few percent framerate improovements for my test models with > osgviewer compared to the case where we force thread safe reference counting > by the environment variable for example. The non thread safe implementations > delivers about the same frame rate than the atomic reference count one on > x86_64. > The memory consumption of Referenced itself is one pointer fewer when using > atomic ops. > > I did not test that on windows so far, but took the implementation from some > of my own codes that already works on windows. > In particular, I do not know if the cmake tests will work as is on windows. > > The change is based on revision 8397. > > Comments? > > Mathias > > -- > Dr. Mathias Fröhlich, science + computing ag, Software Solutions > Hagellocher Weg 71-75, D-72070 Tuebingen, Germany > Phone: +49 7071 9457-268, Fax: +49 7071 9457-511 > -- > Vorstand/Board of Management: > Dr. Bernd Finkbeiner, Dr. Florian Geyer, > Dr. Roland Niemeier, Dr. Arno Steitz, Dr. Ingrid Zech > Vorsitzender des Aufsichtsrats/ > Chairman of the Supervisory Board: > Prof. Dr. Hanns Ruder > Sitz/Registered Office: Tuebingen > Registergericht/Registration Court: Stuttgart > Registernummer/Commercial Register No.: HRB 382196 > > > _______________________________________________ > osg-submissions mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org > > _______________________________________________ osg-submissions mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
