From: Joshua J. <wan...@me...> - 2005-02-16 06:16:42
|
On Feb 15, 2005, at 4:58 PM, Paul Nolan wrote: >> wrt smart pointers in general -- the boost library has come on a long >> way in the last few years, and their smart_ptr will likely be in the >> next version of the standard library. It's not thread-safe, but might >> suffice for your purposes. Generally, unless you're assigning *to* a >> shared smart pointer you only need to update the count manipulation >> with atomic ops. If you are assigning to a shared smart pointer it's >> often better to simply protect it with some synchronization entity -- >> it's possible to update a couple of pointers and an associated count >> safely on PPC using address reservation instructions, and apparently >> it's also possible on x86, but I suspect it'll need some post Pentium >> I >> instruction to do so. > > Ah, I think I see what they were talking about on the boost list now > when > they said smart_ptrs are not thread safe, would I be right in thinking > a > ZRef would also need synchronization when assigning? I was hoping to > find > a reallysmart_ptr I could just use without having to worry about, do > you > have any recommendations? I`d happily trade some speed in the non > speed > critical parts of my software if it reduced the amount of time I spent > debugging multithreaded issues. You could (copy and) modify a smart pointer template to perform the unsafe operations inside a critical region. This might be an example of policy that's a candidate for being a template parameter. Now that I think of it, Alexandrescu may have discussed this already in his book. Personally, I've been using cooperative threads, so the dynamic scope between every consecutive pair of yield calls is automatically a critical region. :-) Josh -- Joshua Juran Metamage Software Creations - Mac Software and Consulting http://www.metamage.com/ * Creation at the highest state of the art * |