Skip to content
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

Closed

Conversation

@addaleax
Copy link
Member

commented Jul 15, 2019

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_ptrs
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.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
@nodejs-github-bot

This comment has been minimized.

@addaleax addaleax force-pushed the addaleax:native-immediate-type-erasure branch from ff700c2 to 0386696 Jul 15, 2019

@nodejs-github-bot

This comment has been minimized.

@addaleax addaleax force-pushed the addaleax:native-immediate-type-erasure branch from 0386696 to 3cf4e25 Jul 20, 2019

static_cast<PerformanceGCKind>(type),
state->performance_last_gc_start_mark,
PERFORMANCE_NOW());
env->SetUnrefImmediate([entry = std::move(entry)](Environment* env) mutable {

This comment has been minimized.

Copy link
@Fishrock123

Fishrock123 Jul 24, 2019

Member

Why does this need mutable?

This comment has been minimized.

Copy link
@addaleax

addaleax Jul 24, 2019

Author Member

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?

@addaleax

This comment has been minimized.

Copy link
Member Author

commented Jul 24, 2019

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.

@nodejs-github-bot

This comment has been minimized.

src: allow generic C++ callables in SetImmediate()
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.

@addaleax addaleax force-pushed the addaleax:native-immediate-type-erasure branch from 6c0712f to 9d04047 Jul 26, 2019

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

@addaleax

This comment has been minimized.

Copy link
Member Author

commented Jul 28, 2019

CI is yellow, so I think this could use a review :)

@addaleax

This comment has been minimized.

Copy link
Member Author

commented Jul 31, 2019

Landed in 5207dec

@addaleax addaleax closed this Jul 31, 2019

@addaleax addaleax deleted the addaleax:native-immediate-type-erasure branch Jul 31, 2019

addaleax added a commit that referenced this pull request Jul 31, 2019
src: allow generic C++ callables in SetImmediate()
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>
targos added a commit that referenced this pull request Aug 2, 2019
src: allow generic C++ callables in SetImmediate()
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>
@BridgeAR BridgeAR referenced this pull request Aug 6, 2019
JeniaBR added a commit to JeniaBR/node that referenced this pull request Sep 11, 2019
src: allow generic C++ callables in SetImmediate()
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: nodejs#28704
Reviewed-By: James M Snell <jasnell@gmail.com>
JeniaBR added a commit to JeniaBR/node that referenced this pull request Sep 11, 2019
src: allow generic C++ callables in SetImmediate()
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: nodejs#28704
Reviewed-By: James M Snell <jasnell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.