Running method while destroying the object

前端 未结 8 1583
抹茶落季
抹茶落季 2021-01-12 22:49

A few days ago my friend told me about the situation, they had in their project. Someone decided, that it would be good to destroy the object of NotVerySafeClass

8条回答
  •  臣服心动
    2021-01-12 23:37

    Simple answer: no.

    Somewhat longer answer: you could guard each and every member function and the destructor in your class with a mutex... welcome to deadlock opportunities and performance nightmares.

    Gather a mob and beat some design sense into the 'someone' who thought parallel destruction was a good idea :)

提交回复
热议问题