diff options
author | andy finch <andyfinch7@gmail.com> | 2019-06-13 23:43:54 -0400 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-06-13 20:43:54 -0700 |
commit | dc60fe9f300043f191286ef804a365e16e455f87 (patch) | |
tree | c6b74e9faa6f26745b8770a18d0ae46ee34f3774 /core/libdeno/api.cc | |
parent | fdd2eb538327ee3f50fe2869320411191830c985 (diff) |
Refactor dispatch handling (#2452)
Promise id is now created in core and passed back to JS.
Diffstat (limited to 'core/libdeno/api.cc')
-rw-r--r-- | core/libdeno/api.cc | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/core/libdeno/api.cc b/core/libdeno/api.cc index 8a3a56156..30f82b6cc 100644 --- a/core/libdeno/api.cc +++ b/core/libdeno/api.cc @@ -153,11 +153,15 @@ void deno_pinned_buf_delete(deno_pinned_buf* buf) { auto _ = deno::PinnedBuf(buf); } -void deno_respond(Deno* d_, void* user_data, deno_buf buf) { +void deno_respond(Deno* d_, void* user_data, deno_buf buf, int* promise_id) { auto* d = unwrap(d_); if (d->current_args_ != nullptr) { // Synchronous response. - if (buf.data_ptr != nullptr) { + if (promise_id != nullptr) { + auto number = v8::Number::New(d->isolate_, *promise_id); + d->current_args_->GetReturnValue().Set(number); + } else { + CHECK_NOT_NULL(buf.data_ptr); auto ab = deno::ImportBuf(d, buf); d->current_args_->GetReturnValue().Set(ab); } |