-
Notifications
You must be signed in to change notification settings - Fork 501
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
No copy or move in NanCallback and NanAsyncWorker #331
Conversation
Instead of declaring the copy/move constructors and operators by hand, perhaps it's better to capture the logic in a NAN_DISALLOW_COPY_MOVE_ASSIGN macro, with one commit introducing the macro and updating existing declarations, and a second commit to update NanAsyncWorker. |
Seems reasonable. This code exists in three places already, and I know there are some other classes (maybe |
Not sure about this. Maybe it has been discussed elsewhere but isn't this a perfect application for a persistent with copy semantics? Non-copyable objects are so... awkward. |
One problem with copyable persistent handles (at least, how they are currently implemented in V8), is that only the storage cell is cloned, not the auxiliary data. You can, for example, copy a weak persistent handle but the resulting handle will be strongly persistent. That may be a non-issue for NanCallback but it's a big headache in general. Non-copyable is just easier to reason about. |
Should all of these be made to disallow copy, assign and move? |
The default v8::Persistent is non-copyable in io.js and node.js v0.12 so their containers should be effectively non-copyable either. Apropos move semantics, I think it should be alright to allow that but I haven't tested and I'm not 100% sure. |
It was you who originally suggested disallowing move for |
There. |
I think in that particular case it was to make sure that ExecutionState doesn't outlive the scope of the Execute callback. That's probably not a consideration for v8::Persistent. At any rate, I don't mind taking a reactive approach and keep everything non-moveable until someone complains. |
LGTM with two suggestions. |
Done. I'll leave this open for a while. |
LGTM with one more suggestion. |
Thanks. Merging, |
No assign, copy or move in classes that can't handle it.
�Fixes #330
Made the same changes to
NanAsyncWorker
, since it too contains aPersistent<T>
.PTAL