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: make Environment optional for RunAtExit #9097

Closed
wants to merge 2 commits into from

Conversation

danbev
Copy link
Contributor

@danbev danbev commented Oct 14, 2016

Checklist
  • make -j8 test (UNIX), or vcbuild test nosign (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

src

Description of change

Currently, the RunAtExit function definition does not use the
Environment parameter. This commit makes the parameter optional
and removes it from the call site.

I noticed this when trying to figure out how to tackle the TODO for
RunAtExit which part of #4641.

Currently, the RunAtExit function definition does not use the
Environment parameter. This commit makes the parameter optional
and removes it from the call site.

I noticed this when trying to figure out how to tackle the TODO for
RunAtExit which part of nodejs#4641.
@nodejs-github-bot nodejs-github-bot added the c++ Issues and PRs that require attention from people who are familiar with C++. label Oct 14, 2016
@addaleax
Copy link
Member

Hmmm – if you introduce a default parameter, shouldn’t that happen in the header where it’s declared (node.cc:212)? I would kind of expect not having a default parameter in the declaration but in the definition to throw the compiler off a bit.

CI: https://ci.nodejs.org/job/node-test-commit/5624/

@danbev
Copy link
Contributor Author

danbev commented Oct 15, 2016

Hmmm – if you introduce a default parameter, shouldn’t that happen in the header where it’s declared (node.cc:212)?

Sorry I got that backward when reading about default parameters and it's exactly like you stated. I'll add this to the declaration in the header and not in the definition. Thanks!

@danbev
Copy link
Contributor Author

danbev commented Oct 15, 2016

@bnoordhuis
Copy link
Member

I'm -1 on this change, it leaks an implementation detail into a public header and those tend to be excruciatingly painful to change later on. Which TODO are you trying to address?

@danbev
Copy link
Contributor Author

danbev commented Oct 16, 2016

Which TODO are you trying to address?

I was looking at this TODO and noticed that the Environment parameter was not being used and though this might be an option. I'm happy to close this and continue/have a new discussion on the other issue.

@danbev danbev closed this Oct 16, 2016
@bnoordhuis
Copy link
Member

Ah, so the idea is that at_exit_functions_ should be a per-environment property rather than a global but that is made difficult by the fact that AtExit() doesn't take an Environment pointer.

There are several ways to skin that cat though. API break, function overload, storing the environment in a thread-local, etc. Writing the code probably won't be that complicated, it's more a matter of figuring out what the best solution long-term is.

@danbev
Copy link
Contributor Author

danbev commented Oct 17, 2016

@bnoordhuis Thanks, I'll take a closer look and create a new PR for discussion.

@danbev
Copy link
Contributor Author

danbev commented Oct 18, 2016

@bnoordhuis I've taken a stab at this in #9163

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants