From cdba5ab6fc633606aaa6f95d0825832c3ac6fe5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Sat, 8 Feb 2020 20:34:31 +0100 Subject: refactor: rename ThreadSafeState, use RefCell for mutable state (#3931) * rename ThreadSafeState to State * State stores InnerState wrapped in Rc and RefCell --- cli/ops/fetch.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'cli/ops/fetch.rs') 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, ) -> Result { @@ -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))), ); -- cgit v1.2.3