I am wondering if there are any plans, either in the near or
distant future, to ever add synchronization support for arbitrary
objects. 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.
Has this ever been considered in the past?