Skip to content

Commit

Permalink
feat: add bindings to run microtasks from Isolate (#2793)
Browse files Browse the repository at this point in the history
  • Loading branch information
bartlomieju authored and ry committed Sep 12, 2019
1 parent 69e01c2 commit c03cdcc
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core/libdeno.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 9 additions & 0 deletions core/libdeno/api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
1 change: 1 addition & 0 deletions core/libdeno/deno.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions core/libdeno/modules.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit c03cdcc

Please sign in to comment.