on Mon Aug 25 2008, Zach Turner
I am wondering if there are any plans, either in the near or distant future, to ever add synchronization support for arbitrary objects.
None that I know of.
The interface could be simple, every class takes one additional template argument,
!!
the class name of a locking object which defaults to some class that provides stub methods so that by default all classes are unsychronized. Then, if I want my object to become synchronized, I can pass it whatever type of lock I deem appropriate. Of course any object can be synchronized currently by making a class that exposes the same interface and acquires a lock before forwarding to the internal boost implementation, but this is inefficient, as the internal details of the object’s implementation are not always such that an entire method needs to be locked. Perhaps only a single line of code inside a long method needs to be locked.
Not to mention which, object-level synchronization is also often underperforming: http://www.sgi.com/tech/stl/thread_safety.html -- Dave Abrahams BoostPro Computing http://www.boostpro.com