mirror of
https://github.com/denoland/deno.git
synced 2025-01-10 16:11:13 -05:00
feat: add bindings to run microtasks from Isolate (#2793)
This commit is contained in:
parent
69e01c2374
commit
c03cdcc939
4 changed files with 13 additions and 0 deletions
|
@ -280,6 +280,8 @@ extern "C" {
|
|||
js_source: *const c_char,
|
||||
);
|
||||
pub fn deno_terminate_execution(i: *const isolate);
|
||||
#[allow(dead_code)]
|
||||
pub fn deno_run_microtasks(i: *const isolate, user_data: *const c_void);
|
||||
|
||||
// Modules
|
||||
|
||||
|
|
|
@ -233,4 +233,13 @@ void deno_terminate_execution(Deno* d_) {
|
|||
deno::DenoIsolate* d = reinterpret_cast<deno::DenoIsolate*>(d_);
|
||||
d->isolate_->TerminateExecution();
|
||||
}
|
||||
|
||||
void deno_run_microtasks(Deno* d_, void* user_data) {
|
||||
deno::DenoIsolate* d = reinterpret_cast<deno::DenoIsolate*>(d_);
|
||||
|
||||
deno::UserDataScope user_data_scope(d, user_data);
|
||||
v8::Locker locker(d->isolate_);
|
||||
v8::Isolate::Scope isolate_scope(d->isolate_);
|
||||
d->isolate_->RunMicrotasks();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -119,6 +119,7 @@ const char* deno_last_exception(Deno* d);
|
|||
|
||||
void deno_terminate_execution(Deno* d);
|
||||
|
||||
void deno_run_microtasks(Deno* d, void* user_data);
|
||||
// Module API
|
||||
|
||||
typedef int deno_mod;
|
||||
|
|
|
@ -213,6 +213,7 @@ void deno_dyn_import_done(Deno* d_, void* user_data,
|
|||
Local<Value> module_namespace = module->GetModuleNamespace();
|
||||
promise->Resolve(context, module_namespace).ToChecked();
|
||||
}
|
||||
d->isolate_->RunMicrotasks();
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
|
Loading…
Reference in a new issue