[cpp-threads] High-level concurrency issues
Peter Dimov
pdimov at mmltd.net
Tue Oct 18 18:42:09 BST 2005
Herb Sutter wrote:
>> But
>> in most cases, it seems to work tolerably well, and layers of calls
>> seem to compose reasonably. And I'm not 100% convinced that the
>> cases in which it breaks don't have single-threaded lock-free
>> analogs in which I break object invariants with an unintentional
>> recursive call.
>
> I'd be interested to see analogs.
The general case is a class making an external call while one of its
invariants temporarily doesn't hold. Note that this is independent of
threads or locks. The lock case is a specific instance where the invariant
is "no internal locks are held".
One simple example is
v.insert( v.begin(), x );
where the vector can make an external call to the copy constructor or
assignment operator of X while being in an inconsistent state.
More information about the cpp-threads
mailing list