summaryrefslogtreecommitdiff
path: root/libdeno
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2018-09-05 22:13:36 -0400
committerRyan Dahl <ry@tinyclouds.org>2018-09-09 18:47:22 -0400
commit0d03fafbfec4545098023b7147c5f8fb6ae06f99 (patch)
treef7c3e10ac0956c4a1ae19c91a711de54de677965 /libdeno
parentff6eefdf87560986274799132d44b00e0a288c21 (diff)
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.
Diffstat (limited to 'libdeno')
-rw-r--r--libdeno/binding.cc10
1 files changed, 10 insertions, 0 deletions
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);
}