mirror of
https://github.com/denoland/rusty_v8.git
synced 2025-03-09 13:38:51 -04:00
Add Isolate::has_pending_background_tasks (#724)
This commit is contained in:
parent
1e533a152e
commit
45006fb7e7
3 changed files with 14 additions and 1 deletions
|
@ -312,6 +312,10 @@ void v8__Isolate__SetWasmStreamingCallback(v8::Isolate* isolate,
|
|||
isolate->SetWasmStreamingCallback(callback);
|
||||
}
|
||||
|
||||
bool v8__Isolate__HasPendingBackgroundTasks(v8::Isolate* isolate) {
|
||||
return isolate->HasPendingBackgroundTasks();
|
||||
}
|
||||
|
||||
void v8__Isolate__CreateParams__CONSTRUCT(
|
||||
uninit_t<v8::Isolate::CreateParams>* buf) {
|
||||
construct_in_place<v8::Isolate::CreateParams>(buf);
|
||||
|
|
|
@ -232,11 +232,11 @@ extern "C" {
|
|||
function: *const Function,
|
||||
);
|
||||
fn v8__Isolate__SetAllowAtomicsWait(isolate: *mut Isolate, allow: bool);
|
||||
|
||||
fn v8__Isolate__SetWasmStreamingCallback(
|
||||
isolate: *mut Isolate,
|
||||
callback: extern "C" fn(*const FunctionCallbackInfo),
|
||||
);
|
||||
fn v8__Isolate__HasPendingBackgroundTasks(isolate: *const Isolate) -> bool;
|
||||
|
||||
fn v8__HeapProfiler__TakeHeapSnapshot(
|
||||
isolate: *mut Isolate,
|
||||
|
@ -655,6 +655,13 @@ impl Isolate {
|
|||
unsafe { v8__Isolate__SetWasmStreamingCallback(self, trampoline::<F>()) }
|
||||
}
|
||||
|
||||
/// Returns true if there is ongoing background work within V8 that will
|
||||
/// eventually post a foreground task, like asynchronous WebAssembly
|
||||
/// compilation.
|
||||
pub fn has_pending_background_tasks(&self) -> bool {
|
||||
unsafe { v8__Isolate__HasPendingBackgroundTasks(self) }
|
||||
}
|
||||
|
||||
/// Disposes the isolate. The isolate must not be entered by any
|
||||
/// thread to be disposable.
|
||||
unsafe fn dispose(&mut self) {
|
||||
|
|
|
@ -4726,6 +4726,7 @@ fn wasm_streaming_callback() {
|
|||
.then(result => globalThis.result = result);
|
||||
"#;
|
||||
eval(scope, script).unwrap();
|
||||
assert!(scope.has_pending_background_tasks());
|
||||
|
||||
let global = context.global(scope);
|
||||
let name = v8::String::new(scope, "result").unwrap().into();
|
||||
|
@ -4739,6 +4740,7 @@ fn wasm_streaming_callback() {
|
|||
assert!(global.get(scope, name).unwrap().is_null());
|
||||
|
||||
ws.finish();
|
||||
assert!(!scope.has_pending_background_tasks());
|
||||
assert!(global.get(scope, name).unwrap().is_null());
|
||||
|
||||
scope.perform_microtask_checkpoint();
|
||||
|
|
Loading…
Add table
Reference in a new issue