[Insight-developers] Re: LightObject race condition fix

Steve M. Robbins steve at sumost.ca
Mon Aug 6 16:30:11 EDT 2007


Hi Simon,

I made the same objection originally, but I later realized it is a
faulty design.

http://www.itk.org/mailman/private/insight-developers/2007-July/009239.html


On Mon, Aug 06, 2007 at 12:29:58PM -0400, Simon Warfield wrote:

> So imagine the following sequence of events:
> Object A in thread 1 calls UnRegister() on a LightObject L shared across 
> threads.
>
> L obtains a lock, and decrements the temporary reference count to be equal 
> to zero, and releases the lock.
>
> Object B in thread 2 , unaware that Object A has asked L to destroy itself, 
> calls Register().

The error is this: Object B must have a reference for L before calling
any method of L, e.g. Register().  Then there is no problem: Object A
is not decrementing L's reference count to 0.

Cheers,
-Steve
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.itk.org/mailman/private/insight-developers/attachments/20070806/9e3649cf/attachment.pgp


More information about the Insight-developers mailing list