node-libvirt icon indicating copy to clipboard operation
node-libvirt copied to clipboard

refactor(NLVObject): use smart pointers for tracking object lifetime

Open Rush opened this issue 9 years ago • 3 comments

@mbroadst I had a lazy evening and a crazy idea to use weak pointers instead of NLVObjectPtr. Note: enable_shared_from_this is probably not necessary but I wanted you to see this branch earlier rather than later to get some comments.

Rush avatar Aug 27 '16 09:08 Rush

yeah definitely now that we've committed to c++11, smart pointers are of course the way to go :)

mbroadst avatar Aug 27 '16 12:08 mbroadst

@Rush I left a few comments. I really like the direction this is taking, but I wonder if we can't split the single commit into at least two:

  • one for the move to std::unique_ptr + all of the handle_ => handle() changes
  • one for your idea with std::shared_ptr

It's a bit hard to review this mono-commit version because of all the handle_ => handle() noise, and frankly I would merge that one right in because it's pretty straightforward and obviously the better solution.

Thoughts?

mbroadst avatar Aug 27 '16 12:08 mbroadst

Sure, I'll split it later this evening probably. Thanks for leaving the comments.

Rush avatar Aug 27 '16 17:08 Rush