-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How smart is Ptr
?
#510
Comments
Thanks for these points -- they highlight some areas that we need to clarify in the documentation, as the need for thread safety when in debug mode with The Indeed, The All of that being said, you are right that the current implementation is not thread safe when in debug mode, and that's something that we need to fix. And, of course, the points above need to be clarified in the documentation. Thanks again -- we appreciate the feedback. |
Makes sense to me. Feel free to close, unless you want to keep it open to track the thread safety issue. |
Closing this and opening an issue specifically on the thread safe issue 👍 |
(Part of openjournals/joss-reviews#6617)
This section of the documentation suggests that
Ptr
is not smart, i.e., does not delete its contents upon destruction. I also had a look at the code and it seems thatPtr
destruction triggers a decrement but not any deletion; an explicit call toDelete()
is required.This is fine if
Ptr
is intended as an exact replacement for a raw pointer (perhaps the docs could be more explicit about that). But it does seem like a missed opportunity for this library. Much of "modern C++" is moving towards smart pointers due to the ease of automatic memory management, and so it is unfortunate thatemp::Ptr
does not provide that.On a related note, it appears that
Ptr
construction may not be thread-safe, due to the class-globalPtrTracker
that tracks all pointers. I don't see any locks to protect modifications forNew()
, etc., which may cause problems when used with OpenMP or by (Emscripten) PThreads. By comparison,std::shared_ptr
operations are thread-safe.The text was updated successfully, but these errors were encountered: