SafePointer thread safe?

I’d like a detached thread to abort when a Component is destroyed by continuously checking whether the Component has been destroyed. Is SafePointer a good choice or is it not thread safe to use on a thread?

I don’t think it’s a good design. Any component related access should be done in the message thread or under a mml-lock (which imho is not a good design either). The safe-pointer does not guarantee that the component is removed under the hand in the thread. If you want that the thread only lives when the component is existing, you might want to shut it down in the destructor of the component (which of cause brings other flaws)

PS: or some kind of mechanism that the component detach itself from the thread in a safe way (probably using locks)

1 Like