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

[Merged by Bors] - API to construct a NativeFunction from a native async function #2542

Closed
wants to merge 13 commits into from
Prev Previous commit
Next Next commit
Replace futures-lite with pollster
  • Loading branch information
jedel1043 committed Feb 24, 2023
commit 4ae9a1bb9a801abd52a0a80af35ae05638beff50
10 changes: 8 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion boa_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ serde_json = "1.0.93"
colored = "2.0.0"
regex = "1.7.1"
phf = { version = "0.11.1", features = ["macros"] }
futures-lite = "1.12.0"
pollster = "0.3.0"

[features]
default = ["intl"]
Expand Down
2 changes: 1 addition & 1 deletion boa_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ impl JobQueue for Jobs {
}

fn enqueue_future_job(&self, future: FutureJob, _: &mut Context<'_>) {
let job = futures_lite::future::block_on(future);
let job = pollster::block_on(future);
self.0.borrow_mut().push_front(job);
}
}
4 changes: 2 additions & 2 deletions boa_engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ intl = [
"dep:icu_collator",
"dep:icu_list",
"dep:writeable",
"dep:sys-locale",
"dep:sys-locale"
]

fuzz = ["boa_ast/arbitrary", "boa_interner/arbitrary"]
Expand Down Expand Up @@ -64,7 +64,7 @@ static_assertions = "1.1.0"
thiserror = "1.0.38"
dashmap = "5.4.0"
num_enum = "0.5.10"
futures-lite = "1.12.0"
pollster = "0.3.0"

# intl deps
boa_icu_provider = { workspace = true, optional = true }
Expand Down
4 changes: 2 additions & 2 deletions boa_engine/src/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl NativeJob {
}
}

/// [`JobCallback`][spec] records
/// [`JobCallback`][spec] records.
///
/// [spec]: https://tc39.es/ecma262/#sec-jobcallback-records
#[derive(Trace, Finalize)]
Expand Down Expand Up @@ -232,7 +232,7 @@ impl JobQueue for SimpleJobQueue {
}

fn enqueue_future_job(&self, future: FutureJob, context: &mut Context<'_>) {
let job = futures_lite::future::block_on(future);
let job = pollster::block_on(future);
self.enqueue_promise_job(job, context);
}
}
3 changes: 1 addition & 2 deletions boa_engine/src/native_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use std::future::Future;

use boa_gc::{custom_trace, Finalize, Gc, Trace};
use futures_lite::FutureExt;

use crate::{
builtins::Promise,
Expand Down Expand Up @@ -195,7 +194,7 @@ impl NativeFunction {
};
context
.job_queue()
.enqueue_future_job(future.boxed_local(), context);
.enqueue_future_job(Box::pin(future), context);
Ok(promise.into())
})
}
Expand Down