From 0d03fafbfec4545098023b7147c5f8fb6ae06f99 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Wed, 5 Sep 2018 22:13:36 -0400 Subject: Map promises onto futures. Refactors handlers.rs The idea is that all Deno "ops" (aka bindings) should map onto a Rust Future. By setting the "sync" flag in the Base message users can determine if the future is executed immediately or put on the event loop. In the case of async futures, a promise is automatically created. Errors are automatically forwarded and raised. TODO: - The file system ops in src/handler.rs are not using the thread pool yet. This will be done in the future using tokio_threadpool::blocking. That is, if you try to call them asynchronously, you will get a promise and it will act asynchronous, but currently it will be blocking. - Handlers in src/handler.rs returned boxed futures. This was to make it easy while developing. We should try to remove this allocation. --- libdeno/binding.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'libdeno/binding.cc') diff --git a/libdeno/binding.cc b/libdeno/binding.cc index 7a79bf199..8ca34684b 100644 --- a/libdeno/binding.cc +++ b/libdeno/binding.cc @@ -11,6 +11,14 @@ #include "deno.h" #include "internal.h" +void hexdump(const uint8_t* buf, size_t len) { + for (size_t i = 0; i < len; ++i) { + char ch = buf[i]; + printf("%02x ", ch & 0xff); + } + printf("\n"); +} + namespace deno { Deno* FromIsolate(v8::Isolate* isolate) { @@ -429,6 +437,8 @@ int deno_send(Deno* d, deno_buf buf) { } void deno_set_response(Deno* d, deno_buf buf) { + // printf("deno_set_response: "); + // hexdump(buf.data_ptr, buf.data_len); auto ab = deno::ImportBuf(d->isolate, buf); d->currentArgs->GetReturnValue().Set(ab); } -- cgit v1.2.3