-
Notifications
You must be signed in to change notification settings - Fork 30k
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
src: allow generic C++ callables in SetImmediate() #28704
Conversation
ff700c2
to
0386696
Compare
0386696
to
3cf4e25
Compare
static_cast<PerformanceGCKind>(type), | ||
state->performance_last_gc_start_mark, | ||
PERFORMANCE_NOW()); | ||
env->SetUnrefImmediate([entry = std::move(entry)](Environment* env) mutable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this need mutable
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because here entry
is moved again out of the function, and so it needs to be modifiable – Do you think a comment would help/be necessary here?
Fwiw, I requested access to CI machines for debugging in nodejs/build#1875 because I really can’t figure out why this would crash, although it’s (probably?) a problem with the relatively overseeable N-API bits here. |
Modify the native `SetImmediate()` functions to take generic C++ callables as arguments. This makes passing arguments to the callback easier, and in particular, it allows passing `std::unique_ptr`s directly, which in turn makes sure that the data they point to is deleted if the `Environment` is torn down before the callback can run.
6c0712f
to
9d04047
Compare
CI is yellow, so I think this could use a review :) |
Landed in 5207dec |
Modify the native `SetImmediate()` functions to take generic C++ callables as arguments. This makes passing arguments to the callback easier, and in particular, it allows passing `std::unique_ptr`s directly, which in turn makes sure that the data they point to is deleted if the `Environment` is torn down before the callback can run. PR-URL: #28704 Reviewed-By: James M Snell <jasnell@gmail.com>
Modify the native `SetImmediate()` functions to take generic C++ callables as arguments. This makes passing arguments to the callback easier, and in particular, it allows passing `std::unique_ptr`s directly, which in turn makes sure that the data they point to is deleted if the `Environment` is torn down before the callback can run. PR-URL: #28704 Reviewed-By: James M Snell <jasnell@gmail.com>
Modify the native
SetImmediate()
functions to take generic C++callables as arguments. This makes passing arguments to the callback
easier, and in particular, it allows passing
std::unique_ptr
sdirectly, which in turn makes sure that the data they point to is
deleted if the
Environment
is torn down before the callback can run.Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes