diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2020-02-08 20:34:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-08 20:34:31 +0100 |
commit | cdba5ab6fc633606aaa6f95d0825832c3ac6fe5c (patch) | |
tree | e8dee2801e14b65b2da6aca62e39cd3d3ac2a786 /cli/ops/fetch.rs | |
parent | 619a24390ff15d5ea5e577a4d0391823f94e8592 (diff) |
refactor: rename ThreadSafeState, use RefCell for mutable state (#3931)
* rename ThreadSafeState to State
* State stores InnerState wrapped in Rc and RefCell
Diffstat (limited to 'cli/ops/fetch.rs')
-rw-r--r-- | cli/ops/fetch.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/cli/ops/fetch.rs b/cli/ops/fetch.rs index 7ce3f1a40..f43133d7f 100644 --- a/cli/ops/fetch.rs +++ b/cli/ops/fetch.rs @@ -3,7 +3,7 @@ use super::dispatch_json::{Deserialize, JsonOp, Value}; use super::io::StreamResource; use crate::http_util::{create_http_client, HttpBody}; use crate::ops::json_op; -use crate::state::ThreadSafeState; +use crate::state::State; use deno_core::*; use futures::future::FutureExt; use http::header::HeaderName; @@ -12,7 +12,7 @@ use http::Method; use std; use std::convert::From; -pub fn init(i: &mut Isolate, s: &ThreadSafeState) { +pub fn init(i: &mut Isolate, s: &State) { i.register_op("fetch", s.core_op(json_op(s.stateful_op(op_fetch)))); } @@ -24,7 +24,7 @@ struct FetchArgs { } pub fn op_fetch( - state: &ThreadSafeState, + state: &State, args: Value, data: Option<ZeroCopyBuf>, ) -> Result<JsonOp, ErrBox> { @@ -65,8 +65,8 @@ pub fn op_fetch( } let body = HttpBody::from(res); - let mut table = state_.lock_resource_table(); - let rid = table.add( + let mut state = state_.borrow_mut(); + let rid = state.resource_table.add( "httpBody", Box::new(StreamResource::HttpBody(Box::new(body))), ); |