So don't do that!
Posted by aogTuesday, 06 October 2009 at 10:28 TrackBack Ping URL

I just have to get this out of my system. Over here is a discussion on memory access ordering semantics and how it relates to C++ synchronization classes. The post is nice but one of the commenters notes that he had problems with using the Boost shared_ptr class in a multi-threaded application by accessing the shared_ptr instances themselves in multiple threads, not the objects to which they pointed. Augh! You’d never do that with ordinary variables, so why expect it to work with shared_ptr? Turing and Church, people are just way too casual about multi-threaded access to data. Back in my day, you would never just share data between threads. Heck, I won’t even share objects via shared_ptr between threads. I always use some higher level locking structure to make sure only one thread is working with an object at any given instant. Of course, I learned about multi-threaded data access back in middle school, hanging out with my buddies, not in some namby-pamby book or highfalutin’ class room. Nothing teaches you to take care of proper synchronization like the mocking laughter of your peers when your data gets corrupted right in front of them. I don’t know what this younger generation is coming to.

Post a comment