[osg-users] Multithreading crashduetoosgDb::Registry::instance()
I-Nixon, Anthony D
anthony.d.nixon at boeing.com
Tue Mar 17 20:42:09 PDT 2009
I'll have a crack at it, unless someone else is already doing it. I've got an environment here that exercises the issue consistently.
Anthony
________________________________
From: Robert Osfield [mailto:robert.osfield at gmail.com]
Sent: Tuesday, 17 March 2009 8:22 PM
To: OpenSceneGraph Users
Subject: Re: [osg-users] Multithreading crashduetoosgDb::Registry::instance()
HI Richard + Paul,
Thanks for explanation. Feel free to dive in an code up such a solution.
Robert.
On Tue, Mar 17, 2009 at 10:17 AM, Schmidt, Richard <Richard.Schmidt at eads.com> wrote:
The document is about a design pattern called double locking, which is especially suitable for singleton objects in multithreaded environments.
The pattern is essentially this:
static Singleton *instance (void)
{
// First check
if (instance_ == 0)
{
// Ensure serialization (guard
// constructor acquires lock_).
Guard<Mutex> guard (lock_);
// Double check.
if (instance_ == 0)
instance_ = new Singleton;
}
return instance_;
// guard destructor releases lock_.
}
The guard mutex is only accessed in the initialization phase of the singleton. Once instance_ is set the guard does not need to be queried anymore.
Richard
_______________________________________
Von: osg-users-bounces at lists.openscenegraph.org [mailto:osg-users-bounces at lists.openscenegraph.org] Im Auftrag von Robert Osfield
Gesendet: Dienstag, 17. März 2009 11:07
An: OpenSceneGraph Users
Betreff: Re: [osg-users] Multithreading crash duetoosgDb::Registry::instance()
2009/3/17 Schmidt, Richard <Richard.Schmidt at eads.com>
http://www.cs.wustl.edu/~schmidt/PDF/DC-Locking.pdf <http://www.cs.wustl.edu/%7Eschmidt/PDF/DC-Locking.pdf>
Could you explain what the above document is all about...
Robert.
_______________________________________________
osg-users mailing list
osg-users at lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20090318/bc2b23e9/attachment-0003.htm>
More information about the osg-users
mailing list