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

WIP: Scheduler #1082

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

SebastianStehle
Copy link
Contributor

WIP for #1081

@SebastianStehle
Copy link
Contributor Author

@twop This is a WIP of POC for the discussion I opened in the discussions.

Please ignore the changes to the *.csproj files. I will revert them if necessary, I was just too lazy to install .NET Framework.

private bool _isRunning;
private bool _isDisposed;

public Task Completion
Copy link
Contributor

Choose a reason for hiding this comment

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

I have a strong opinion that Jint should not have Task as a part of it's API surface area, otherwise there is an implicit promise (no pun intended) of taking care of thread safety, which is not something Jint is interested in (I might be wrong here).

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe as a small piece of "evidence", no JS engines I know provide comprehensive async support. You basically have to do all the steps I described in the issue in a host environment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you mean with async support?

For me, in this context "async" is everything that is not invoked immedately. SetTimeout, setInterval, Promises, callbacks and so on. Even module loading is actually a promise in javascript.

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean the actual async runtime is usually outside of JS engines, e.g. they have a low level primitive that a hosting environment needs to implement. Specifically: HostEnqueuePromiseJob from the language spec https://www.ecma-international.org/wp-content/uploads/ECMA-262_12th_edition_june_2021.pdf

Copy link
Collaborator

Choose a reason for hiding this comment

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

Here's a bit easier link: https://tc39.es/ecma262/#sec-hostenqueuepromisejob , I haven't really gone into this but basically custom hosts should be possible in Jint (we should make it so and improve when features are missing), there's already the Host concept and ideally Jint would have all expected behavior and allow adding missing more controversial bits.

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