s/PinnedBuf/ZeroCopyBuf (#3782)

This commit is contained in:
Ryan Dahl 2020-01-24 15:10:49 -05:00 committed by GitHub
parent 86726f88f1
commit 5e32c5ea44
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
32 changed files with 145 additions and 138 deletions

View file

@ -15,8 +15,8 @@ use deno_core::ErrBox;
use deno_core::Loader;
use deno_core::ModuleSpecifier;
use deno_core::Op;
use deno_core::PinnedBuf;
use deno_core::ResourceTable;
use deno_core::ZeroCopyBuf;
use futures::channel::mpsc;
use futures::future::FutureExt;
use futures::future::TryFutureExt;
@ -83,13 +83,13 @@ impl ThreadSafeState {
pub fn core_op<D>(
&self,
dispatcher: D,
) -> impl Fn(&[u8], Option<PinnedBuf>) -> CoreOp
) -> impl Fn(&[u8], Option<ZeroCopyBuf>) -> CoreOp
where
D: Fn(&[u8], Option<PinnedBuf>) -> CoreOp,
D: Fn(&[u8], Option<ZeroCopyBuf>) -> CoreOp,
{
let state = self.clone();
move |control: &[u8], zero_copy: Option<PinnedBuf>| -> CoreOp {
move |control: &[u8], zero_copy: Option<ZeroCopyBuf>| -> CoreOp {
let bytes_sent_control = control.len();
let bytes_sent_zero_copy =
zero_copy.as_ref().map(|b| b.len()).unwrap_or(0);
@ -126,13 +126,13 @@ impl ThreadSafeState {
pub fn stateful_minimal_op<D>(
&self,
dispatcher: D,
) -> impl Fn(i32, Option<PinnedBuf>) -> Pin<Box<MinimalOp>>
) -> impl Fn(i32, Option<ZeroCopyBuf>) -> Pin<Box<MinimalOp>>
where
D: Fn(&ThreadSafeState, i32, Option<PinnedBuf>) -> Pin<Box<MinimalOp>>,
D: Fn(&ThreadSafeState, i32, Option<ZeroCopyBuf>) -> Pin<Box<MinimalOp>>,
{
let state = self.clone();
move |rid: i32, zero_copy: Option<PinnedBuf>| -> Pin<Box<MinimalOp>> {
move |rid: i32, zero_copy: Option<ZeroCopyBuf>| -> Pin<Box<MinimalOp>> {
dispatcher(&state, rid, zero_copy)
}
}
@ -145,15 +145,19 @@ impl ThreadSafeState {
pub fn stateful_op<D>(
&self,
dispatcher: D,
) -> impl Fn(Value, Option<PinnedBuf>) -> Result<JsonOp, ErrBox>
) -> impl Fn(Value, Option<ZeroCopyBuf>) -> Result<JsonOp, ErrBox>
where
D: Fn(&ThreadSafeState, Value, Option<PinnedBuf>) -> Result<JsonOp, ErrBox>,
D: Fn(
&ThreadSafeState,
Value,
Option<ZeroCopyBuf>,
) -> Result<JsonOp, ErrBox>,
{
let state = self.clone();
move |args: Value, zero_copy: Option<PinnedBuf>| -> Result<JsonOp, ErrBox> {
dispatcher(&state, args, zero_copy)
}
move |args: Value,
zero_copy: Option<ZeroCopyBuf>|
-> Result<JsonOp, ErrBox> { dispatcher(&state, args, zero_copy) }
}
}