On Nov 30, 2007, at 11:44 AM, Paul Martz wrote:

> Can someone explain the difference between Mutex and ReentrantMutex?  
> The code comments are practically non-existent, the code itself  
> seems somewhat un-illuminating, and the ChangeLog just says things  
> like "Added ReentrantMutex to fix Font problems" but doesn't explain  
> what the problem was, or how ReentrantMutex fixed the problem and  
> why Mutex couldn't fix the problem.

i believe you'd use ReentrantMutex to lock a critical section which  
was recursive. it looks like all the explanatory code you get is in  
the 'lock()' method:

  - lock: if you call lock on this mutex from the thread that already
    has acquired this lock, you simply increment your reference count

  - unlcok: when called, the code simply decrements the active lock
    count.*

this seems to be used in a couple plugins (dae, flt, txp, gdal), but  
perhaps most importantly, in GraphicsContext, as a lock around a map  
containing context ids / context data.

bob

* interestingly the lock/unlock code isn't symmetric. the lock cares  
that it's the same thread relocking this mutex, the unlock does it  
from any thread. there's code indicating that the check at unlock was  
once either tried, or active, but is no longer in-use.

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to