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

refactor: deno_runtime crate #8640

Merged
merged 26 commits into from
Dec 13, 2020

Conversation

bartlomieju
Copy link
Member

@bartlomieju bartlomieju commented Dec 6, 2020

This commit moves Deno JS runtime, ops, permissions and
inspector implementation to new "deno_runtime" crate.

Details in "runtime/README.md".

There is still some duplication of code, but overall diff is quite
small after all the recent refactors.

Closes #7928
Closes #2633

@bartlomieju bartlomieju changed the title [WIP] feat: crate deno runtime [WIP] feat: deno_runtime crate Dec 7, 2020
@bartlomieju bartlomieju requested a review from ry December 12, 2020 00:11
@bartlomieju bartlomieju changed the title [WIP] feat: deno_runtime crate feat: deno_runtime crate Dec 12, 2020
deno_runtime/README.md Outdated Show resolved Hide resolved
@bartlomieju bartlomieju requested a review from ry December 12, 2020 16:57
deno_runtime/Cargo.toml Outdated Show resolved Hide resolved
cli/Cargo.toml Outdated Show resolved Hide resolved
Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

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

It would be really great to have a deno_runtime/examples directory with a basic hello world example.

cli/build.rs Show resolved Hide resolved
@bartlomieju
Copy link
Member Author

It would be really great to have a deno_runtime/examples directory with a basic hello world example.

Added hello_runtime example in runtime/examples/

MainWorker::from_options(main_module.clone(), permissions, &options);
worker.bootstrap(&options);
worker.execute_module(&main_module).await?;
worker.run_event_loop().await?;
Copy link
Member

@ry ry Dec 13, 2020

Choose a reason for hiding this comment

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

Aside: we should change the name of run_event_loop() - it's neither accurate nor descriptive. The event loop is run in tokio. This method waits until all async ops have completed. wait_for_async_ops() or something.

Copy link
Member Author

Choose a reason for hiding this comment

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

We've already talked about it, ops are only one of a few things that are polled in run_event_loop, besides ops there are pending module loads and pending dynamic imports.

Copy link
Member

Choose a reason for hiding this comment

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

wait_for_various_async_things_to_complete() then or wait_until_idle()

Copy link
Member Author

Choose a reason for hiding this comment

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

wait_until_idle() sounds ok, but let's do that in other PR

runtime/build.rs Show resolved Hide resolved
create_runtime_snapshot(&runtime_snapshot_path, js_files);
}

fn get_js_files(d: &str) -> Vec<PathBuf> {
Copy link
Member

Choose a reason for hiding this comment

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

This method is only called once, "d" is always "rt".

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it's copy paste from cli/build.rs, I suggest we do those minor cleanups in follow up PRs

runtime/ops/mod.rs Show resolved Hide resolved
@bartlomieju bartlomieju changed the title feat: deno_runtime crate refactor: deno_runtime crate Dec 13, 2020
cli/build.rs Outdated Show resolved Hide resolved
Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

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

LGTM - nice work.

@bartlomieju bartlomieju merged commit 2e74f16 into denoland:master Dec 13, 2020
@bartlomieju bartlomieju deleted the crate_deno_runtime branch December 13, 2020 18:45
kitsonk pushed a commit to lucacasonato/deno that referenced this pull request Dec 18, 2020
This commit moves Deno JS runtime, ops, permissions and
inspector implementation to new "deno_runtime" crate located
in "runtime/" directory.

Details in "runtime/README.md".

Co-authored-by: Ryan Dahl <[email protected]>
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.

Feature request: CLI available as library Rust library with batteries included
2 participants