Should destructors be threadsafe?

后端 未结 9 1310
误落风尘
误落风尘 2021-02-07 09:08

I was going through a legacy code and found the following snippet:

MyClass::~MyClass()
{
   EnterCriticalSection(&cs);

//Access Data Members, **NO Global**          


        
9条回答
  •  迷失自我
    2021-02-07 09:58

    I second the comment from Neil ButterWorth. Absolutely, the Entities responsible for deleting and accessing the myclass, should have a check on this.

    This synchronisation will start actually from the moment the object of type MyClass is created.

提交回复
热议问题