Skip to content

Add environment to all library methods #82

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

Merged
merged 7 commits into from
Mar 17, 2018
Merged

Add environment to all library methods #82

merged 7 commits into from
Mar 17, 2018

Conversation

cmfcmf
Copy link
Collaborator

@cmfcmf cmfcmf commented Mar 13, 2018

No description provided.

* @return The return value of the given JavaScript file.
*/
NODE_EXTERN v8::MaybeLocal<v8::Value> Run(const std::string& path);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add documentation.

@Johannes-Schneider
Copy link
Collaborator

Would it be a good idea to check, whether we can use Initialize to create mutliple instances of Environment? This would be very convenient for users who might want to use multiple Environment, but dont intend to write all the setup code themselves.

@cmfcmf
Copy link
Collaborator Author

cmfcmf commented Mar 13, 2018

Would it be a good idea to check, whether we can use Initialize to create mutliple instances of Environment? This would be very convenient for users who might want to use multiple Environment, but dont intend to write all the setup code themselves.

I don't think we can easily change our Initialize function to accomplish this, because it initializes a lot more than just the environment (atexit, PlatformInit(), ...). I think it is out of scope for us to make it easier to create multiple environments.

src/node_lib.h Outdated
NODE_EXTERN v8::MaybeLocal<v8::Value> Call(
Environment* env,
v8::Local<v8::Object> receiver,
v8::Local<v8::Function> function,
std::initializer_list<v8::Local<v8::Value>> args);
} // namespace node
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happened here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, that was an accident, fixed it 👍

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just working on the same thing when you started pushing :-D I've now also pushed my commit, which should make this ready.

Copy link
Collaborator

@luminosuslight luminosuslight left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The env parameter has to be added to eventLoopIsRunning, start/stopEventLoop and tickEventLoop, too, and the documentation for internal::isolate()/environment() should be adapted.

I will stop working on it now so that we don't do it twice again :-D 🙈

@cmfcmf
Copy link
Collaborator Author

cmfcmf commented Mar 13, 2018

The env parameter has to be added to eventLoopIsRunning, start/stopEventLoop and tickEventLoop, too,

I'm not sure that's true. Calling tickEventLoop with a different environment meanse calling it with an environment not created by Initialize(). I don't think that's really needed at the moment.

and the documentation for internal::isolate()/environment() should be adapted.

Yes, that's right.

@luminosuslight
Copy link
Collaborator

I'm not sure about this, but shouldn't it be possible to call startEventLoop(env) with an environment created in the same way as in Initialize()? If not, than this parameter is not required, right. We should then document that it is using the env from the Initialize() function.

@cmfcmf
Copy link
Collaborator Author

cmfcmf commented Mar 13, 2018

I'm not sure about this, but shouldn't it be possible to call startEventLoop(env) with an environment created in the same way as in Initialize()? If not, than this parameter is not required, right. We should then document that it is using the env from the Initialize() function.

Well, I think it would be possible in theory, but not worth the hassle at the moment. If you are that advanced to create own environments without using the Initialize function, you might as well write your own event loop.

@cmfcmf cmfcmf changed the title POC of environments in all library methods Add environment to all library methods Mar 17, 2018
@cmfcmf
Copy link
Collaborator Author

cmfcmf commented Mar 17, 2018

Merging based on feedback received on Telegram 🔭

@cmfcmf cmfcmf merged commit 9d6e944 into dev Mar 17, 2018
@cmfcmf cmfcmf deleted the add-environment branch March 17, 2018 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants