[Insight-developers] LightObject race condition fix
Gaëtan Lehmann
gaetan.lehmann at jouy.inra.fr
Mon Aug 6 04:07:19 EDT 2007
Le 12 juil. 07 à 00:31, Peter Cech a écrit :
> On Wed, Jul 11, 2007 at 11:02:16 -0400, Karthik Krishnan wrote:
>> On 7/11/07, Gaëtan Lehmann <gaetan.lehmann at jouy.inra.fr> wrote:
>>>
>>>
>>> Le 11 juil. 07 à 15:33, Karthik Krishnan a écrit :
>>>
>>>> However I agree with Steve/Luis that access of the resource
>>>> m_ReferenceCount be thread safe. One solution would be to use a
>>>> scoped lock (unlocking is implemented in its destructor, so it
>>>> automatically does that when it goes out of scope).
>>>>
>>>> The code would look like
>>>>
>>>> UnRegister()
>>>> {
>>>> ScopedLock lock( m_ReferenceCountLock )
>>>> m_ReferenceCount--;
>>>> if ( m_ReferenceCount <= 0) { delete this; }
>>>> }
>>>
>>> Please correct if I'm wrong, but the mutex lock will be destroyed by
>>> the delete call before the destruction of the ScopedLock object,
>>
>>
>> You're right.. How silly of me :) I'd suggest leaving it as is..
>
> It's past midnight here, so I'll refrain from trying to post any
> solutions, but there is something relevant here:
>
> http://softwarecommunity.intel.com/isn/Community/en-US/forums/
> thread/30225804.aspx
>
> Enjoy!
>
Hi,
I realize I haven't put the changes in the cvs repository.
Can I do that ?
Would be great also to explore Peter's link. It seem quite complex
though, and I didn't get enough time yet to look at it carefully...
Gaëtan
--
Gaëtan Lehmann
Biologie du Développement et de la Reproduction
INRA de Jouy-en-Josas (France)
tel: +33 1 34 65 29 66 fax: 01 34 65 29 09
http://voxel.jouy.inra.fr
More information about the Insight-developers
mailing list