mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
refactor: per-worker resource table (#3306)
- removes global `RESOURCE_TABLE` - resource tables are now created per `Worker` in `State` - renames `CliResource` to `StreamResource` and moves all logic related to it to `cli/ops/io.rs` - removes `cli/resources.rs` - adds `state` argument to `op_read` and `op_write` and consequently adds `stateful_minimal_op` to `State` - IMPORTANT NOTE: workers don't have access to process stdio - this is caused by fact that dropping worker would close stdout for process (because it's constructed from raw handle, which closes underlying file descriptor on drop)
This commit is contained in:
parent
af448e864c
commit
fd62379eaf
14 changed files with 358 additions and 336 deletions
11
cli/lib.rs
11
cli/lib.rs
|
@ -43,7 +43,6 @@ pub mod permissions;
|
|||
mod progress;
|
||||
mod repl;
|
||||
pub mod resolve_addr;
|
||||
pub mod resources;
|
||||
mod shell;
|
||||
mod signal;
|
||||
pub mod source_maps;
|
||||
|
@ -57,6 +56,7 @@ pub mod worker;
|
|||
use crate::deno_error::js_check;
|
||||
use crate::deno_error::print_err_and_exit;
|
||||
use crate::global_state::ThreadSafeGlobalState;
|
||||
use crate::ops::io::get_stdio;
|
||||
use crate::progress::Progress;
|
||||
use crate::state::ThreadSafeState;
|
||||
use crate::worker::Worker;
|
||||
|
@ -128,6 +128,15 @@ fn create_worker_and_state(
|
|||
.map_err(deno_error::print_err_and_exit)
|
||||
.unwrap();
|
||||
|
||||
let state_ = state.clone();
|
||||
{
|
||||
let mut resource_table = state_.lock_resource_table();
|
||||
let (stdin, stdout, stderr) = get_stdio();
|
||||
resource_table.add("stdin", Box::new(stdin));
|
||||
resource_table.add("stdout", Box::new(stdout));
|
||||
resource_table.add("stderr", Box::new(stderr));
|
||||
}
|
||||
|
||||
let worker = Worker::new(
|
||||
"main".to_string(),
|
||||
startup_data::deno_isolate_init(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue