|
Boost : |
From: Hurd, Matthew (hurdm_at_[hidden])
Date: 2004-06-08 19:13:57
> Behalf Of Eric Niebler
> Sent: Wednesday, 9 June 2004 9:15 AM
> To: boost_at_[hidden]
> Subject: [boost] Re: Thread lib (good reason for static)
>
> Hurd, Matthew wrote:
> >>Behalf Of scott
> >>Assume use of a technique like the following (think this has been
> >>presented as "object shim"?);
> >>
> >>T &
> >>anastasia()
> >>{
> >> static T *p = new T;
> >> return *p;
> >>}
> >>
> >>as a means of dealing with global construction issue, i.e. instead
> >>of expressions like "anastasia.data_member" the usage is
> >>"anastasia().data_member". Also assume that some of these global
> >>objects (i.e. shims) deploy mutexes for MT reasons. What happens
> >>when there is more that one thread running around making calls
> >>to shims? Instantiation of the global itself becomes an MT issue.
> >
> >
> > That's what the double-checked locking pattern for singletons is
for.
> >
> > Regards,
> >
> > Matt Hurd.
>
>
> No, the double-checked locking pattern is only good as the subject of
> talks describing why it's not good for anything.
>
> http://www.nwcpp.org/Downloads/2004/DCLP_notes.pdf
Thanks. They are good notes.
I'm aware of the portability issues. Doesn't mean you can't have valid
platform specific singleton implementations that use the double checked
locking pattern. The performance of the approach is too important to
give up. Locking is slow.
There are a lot of things you can't do portability in C++ which is one
rationale for having libraries :-)
Regards,
Matt Hurd.
_______________
Matt Hurd
+61.2.8226.5029
hurdm_at_[hidden]
Susquehanna
_______________
IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk